#include int i, j; int main(){ int n[7][7]; for(i = 1; i <= 7; i++){ for(j = 1; j <= 7; j++){ printf("input (%d,%d): ", i, j); scanf("%d", &n[i][j]); } } //r1 printf("\n\nMATRIX\tColumn1\tColumn2\tColumn3\tColumn4\tColumn5\tColumn6\tColumn7"); for(i = 1; i <= 7; i++){ printf("\nRow%d", i); for(j = 1; j <= 7; j++){ printf("\t%d", n[i][j]); } } //r2 printf("\n\nTotal elements in even rows"); for(i = 1; i <= 7; i++){ int total = 0; if(i % 2 != 0){ for(j = 1; j <= 7; j++){ total += n[i][j]; } printf("\nTotal numbers of column%d = %d", i, total); } } //r3 chinh xac thi bug dang o doan nay`, ascending sort khong het int a; for(a = 1; a <= 7; a++){ for(i = 1; i <= 7; i++){ for(j = 7-1; j > i; j--){ if(n[j-1][a] > n[j][a]){ int temp = n[j-1][a]; n[j-1][a] = n[j][a]; n[j][a] = temp; // int temp = n[j][a]; // n[j][a] = n[j-1][a]; // n[j-1][a] = temp; } } } } printf("\n\nSorted\tColumn1\tColumn2\tColumn3\tColumn4\tColumn5\tColumn6\tColumn7"); for(i = 1; i <= 7; i++){ printf("\nRow%d", i); for(j = 1; j <= 7; j++){ printf("\t%d", n[i][j]); } } return 0; } /* Exercise 5: Write a C program inputs a matrix of integer from the keyboard. Then do following tasks: - Display the given matrix to the screen. - Calculate total elements in even rows. Display result to the screen. - Sorting all columns ascending. Display matrix after sorting to the screen. 23 56 45 85 65 89 65 45 3 16 34 42 12 46 56 78 12 54 87 -9 -8 45 334 54 65 89 1 5 3268 98 7 111 58 89 -100 0 -99 1345 432 1324 77 90 98 13 411 456 234 131 68 */