fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4. int m = 10;
  5. int n = 10;
  6. char board[m][n] = {"a","bcd","efghi"};
  7. int y = 3; // 行数
  8. int x[m] = {1,3,5}; // 各行の長さ
  9. for(int i=0; i<y-1; ++i){
  10. for(int j=i+1; j<y; ++j){
  11. for(int k=x[i]; k<x[j]; ++k)
  12. board[i][k] = board[j][k];
  13. swap(x[i], x[j]);
  14. }
  15. }
  16. for(int k=0; k<y; ++k){
  17. for(int l=0; l<x[k]; ++l)
  18. cout << board[k][l];
  19. cout << endl;
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 4428KB
stdin
Standard input is empty
stdout
acdhi
bfg
e