#include #include #include #include int diff(int s[][3],int m[][3]) { int ans=0,i,j; for(i=0;i<3;i++) { for(j=0;j<3;j++) { ans+=abs(s[i][j]-m[i][j]); } } return ans; } int main() { int i,j,k,max=100,di; int s[3][3],a[3][3]={{2,7,6},{9,5,1},{4,3,8}},b[3][3]={{2,9,4},{7,5,3},{6,1,8}},c[3][3]={{6,1,8},{7,5,3},{2,9,4}}, d[3][3]={{6,7,2},{1,5,9},{8,3,4}},e[3][3]={{8,3,4},{1,5,9},{6,7,2}},f[3][3]={{8,1,6},{3,5,7},{4,9,2}}, g[3][3]={{4,9,2},{3,5,7},{8,1,6}},h[3][3]={{4,3,8},{9,5,1},{2,7,6}}; for(i=0;i<3;i++) { for(j=0;j<3;j++) { scanf("%d",&s[i][j]); } } di=diff(s,a); max=max