#include #include #include #include int main() { int a[3][3],i,j; for(i=0;i<3;++i) { for(j=0;j<3;++j) scanf("%d",&a[i][j]); } int res[8]; for(i=0;i<8;++i){res[i]=0;} int b1[3][3]= { {8,1,6}, {3,5,7}, {4,9,2} }; int b2[3][3]= { {4,3,8}, {9,5,1}, {2,7,6} }; int b3[3][3]= { {2,9,4}, {7,5,3}, {6,1,8} }; int b4[3][3]= { {6,7,2}, {1,5,9}, {8,3,4}, }; int b5[3][3]= { {6,1,8}, {7,5,3}, {2,9,4} }; int b6[5][5]= { {8,3,4}, {1,5,9}, {6,7,2} }; int b7[5][5]= { {4,9,2}, {3,5,7}, {8,1,6} }; int b8[5][5]= { {2,7,6}, {9,5,1}, {4,3,8} }; for(int i=0;i<3;++i) { for(int j=0;j<3;++j) { res[0]+=abs(a[i][j]-b1[i][j]); res[1]+=abs(a[i][j]-b2[i][j]); res[2]+=abs(a[i][j]-b3[i][j]); res[3]+=abs(a[i][j]-b4[i][j]); res[4]+=abs(a[i][j]-b5[i][j]); res[5]+=abs(a[i][j]-b6[i][j]); res[6]+=abs(a[i][j]-b7[i][j]); res[7]+=abs(a[i][j]-b8[i][j]); } } int min=100; for(i=0;i<8;++i) {if(res[i]