PAT L1-072. 刮刮彩票
原题链接
简单
作者:
青丝蛊
,
2021-04-09 16:46:43
,
所有人可见
,
阅读 230
#include <bits/stdc++.h>
using namespace std;
int v[30];
int main()
{
v[6] = 10000;
v[7] = 36;
v[8] = 720;
v[9] = 360;
v[10] = 80;
v[11] = 252;
v[12] = 108;
v[13] = 72;
v[14] = 54;
v[15] = 180;
v[16] = 72;
v[17] = 180;
v[18] = 119;
v[19] = 36;
v[20] = 306;
v[21] = 1080;
v[22] = 144;
v[23] = 1800;
v[24] = 3600;
int a[3][3];
int sum = 0, x, y;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
{
cin >> a[i][j];
sum += a[i][j];
if (!a[i][j])
x = i, y = j;
}
a[x][y] = 45 - sum;
for (int i = 0; i < 3; i++)
{
int x, y;
cin >> x >> y;
cout << a[x - 1][y - 1] << endl;
}
sum = 0;
int t;
cin >> t;
if (t >= 1 && t <= 3)
{
for (int i = 0; i < 3; i++)
sum += a[t - 1][i];
}
else if (t >= 4 && t <= 6)
{
for (int i = 0; i < 3; i++)
sum += a[i][t - 4];
}
else if (t == 7)
{
for (int i = 0; i < 3; i++)
sum += a[i][i];
}
else if (t == 8)
{
for (int i = 0; i < 3; i++)
sum += a[2 - i][i];
}
cout << v[sum] << endl;
return 0;
}