#include #include #include #include #include using namespace std; int sumRow(int n, int matrix[3][3]){ int sum = matrix[n][1] + matrix[n][2] + matrix[n][3]; return sum; } int sumCol(int n, int matrix[3][3]){ int sum = matrix[1][n] + matrix[2][n] + matrix[3][n]; return sum; } int sumDiag(int n, int matrix[3][3]){ int sum; if(n == 0){ int sum = matrix[1][1] + matrix[2][2] + matrix[3][3]; } else{ int sum = matrix[3][1] + matrix[2][2] + matrix[1][3]; } return sum; } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int s[3][3]; int matrix1[3][3]={{8, 1, 6}, {3, 5, 7}, {4, 9, 2}}; int matrix2[3][3]={{4, 3, 8}, {9, 5, 1}, {2, 7, 6}} ; int matrix3[3][3]={{2, 9, 4}, {7, 5, 3}, {6, 1, 8}} ; int matrix4[3][3]={{6, 7, 2}, {1, 5, 9}, {8, 3, 4}} ; int matrix5[3][3]={{6, 1, 8}, {7, 5, 3}, {2, 9, 4}} ; int matrix6[3][3]={{8, 3, 4}, {1, 5, 9}, {6, 7, 2}} ; int matrix7[3][3]={{4, 9, 2}, {3, 5, 7}, {8, 1, 6}} ; int matrix8[3][3]={{2, 7, 6}, {9, 5, 1}, {4, 3, 8}} ; int cost = 0; int min_cost = 45; for(int i=0; i<3; i++){ for(int j=0; j<3; j++){ cin >> s[i][j]; } } for(int i=0; i<3; i++){ for(int j=0; j<3; j++){ cost = cost + abs(s[i][j]-matrix1[i][j]); } } if(cost