Code:
#include<bits/stdc++.h>
using namespace std;
int arr[4][4], p[19] = {10000, 36, 720, 360, 80, 252, 108, 72, 54, 180, 72, 180, 119, 36, 306, 1080, 144, 1800, 3600};
int main(){int zero = 45, posx, posy; //初始是1~9的和for(int i = 1; i <= 3; i++){for(int j = 1; j <= 3; j++){cin >> arr[i][j];if(arr[i][j] == 0) posx = i, posy = j; zero -= arr[i][j]; //最终得到0的真实值}}arr[posx][posy] = zero; //把0替换掉for(int i = 0; i < 3; i++){int x, y;cin >> x >> y;cout << arr[x][y] << endl;}int dirt, res = 0;cin >> dirt;if(dirt < 4){for(int i = 1; i <= 3; i++){res += arr[dirt][i];}}else if(dirt < 7){for(int i = 1; i <= 3; i++){res += arr[i][dirt - 3];}}else if(dirt == 7){res = arr[1][1] + arr[2][2] + arr[3][3];}else{res = arr[1][3] + arr[2][2] + arr[3][1];}cout << p[res - 6];return 0;
}