Skip to content

Commit

Permalink
Create sort_2d_array.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
sarekashi authored Feb 12, 2022
1 parent 2fbba73 commit 3c77f91
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions C++/sort_2d_array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <stdio.h>
#define n1 3
#define n2 5

int main() {
char A[n1][n2] = {'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O'};

printf("Array before sorted: \n");
for (int i = 0; i <= n1-1; ++i) {
for (int j = 0; j <= n2-1; ++j) {
printf("%3c", A[i][j]);
}
printf("\n");
}
printf("\n");

// Process of sorted Array
printf("Array after sorted: \n");
for (int i = 0; i <= n2-1; ++i) {
for (int j = 0; j <= n1-1; ++j) {
printf("%3c", A[j][i]);
}
printf("\n");
}

return 0;
}

0 comments on commit 3c77f91

Please sign in to comment.