把每个数字长什么样存到数组里就好;傻逼题。
(直接输入每一行是什么样子更快,不要一个字符一个字符地输入)
1
#include <bits/stdc++.h>
using namespace std;
int T;
char s[10][30];
char temp[10][10][7];
int get_ans(int x1,int y1,int x2,int y2){
for (int k = 0;k <= 9;k++){
bool ok = true;
for (int i = x1;i <= x2;i++)
for (int j = y1;j <= y2;j++){
if (temp[k][i-x1+1][j-y1+1]!=s[i][j])
ok = false;
}
if (ok) return k;
}
return 2333;
}
int main(){
for (int k = 0;k <= 9;k++)
for (int i = 1;i <= 7;i++)
for (int j = 1;j <= 4;j++)
temp[k][i][j] = '.';
//'0';
for (int i = 2;i <= 3;i++)
temp[0][1][i] = temp[0][7][i] = 'X';
for (int i = 2;i <= 3;i++)
temp[0][i][1] = temp[0][i][4] = 'X';
for (int i = 5;i <= 6;i++)
temp[0][i][1] = temp[0][i][4] = 'X';
//'1';
for (int i = 2;i <= 3;i++)
temp[1][i][4] = 'X';
for (int i = 5;i <= 6;i++)
temp[1][i][4] = 'X';
//'2'
for (int i = 2;i <= 3;i++)
temp[2][1][i] = temp[2][4][i] = temp[2][7][i] = 'X';
for (int i = 2;i <= 3;i++)
temp[2][i][4] = 'X';
for (int i = 5;i <= 6;i++)
temp[2][i][1] = 'X';
//'3'
for (int i = 2;i <= 3;i++)
temp[3][1][i] = temp[3][4][i] = temp[3][7][i] = 'X';
for (int i = 2;i <= 3;i++)
temp[3][i][4] = 'X';
for (int i = 5;i <= 6;i++)
temp[3][i][4] = 'X';
//'4'
for (int i = 2;i <= 3;i++)
temp[4][i][1] = temp[4][i][4] = 'X';
for (int i = 2;i <= 3;i++)
temp[4][4][i] = 'X';
for (int i = 5;i <= 6;i++)
temp[4][i][4] = 'X';
//'5'
for (int i = 2;i <= 3;i++)
temp[5][1][i] = temp[5][4][i] = temp[5][7][i] = 'X';
for (int i = 2;i <= 3;i++)
temp[5][i][1] = 'X';
for (int i = 5;i <= 6;i++)
temp[5][i][4] = 'X';
//'6'
for (int i = 2;i <= 3;i++)
temp[6][1][i] = temp[6][4][i] = temp[6][7][i] = 'X';
for (int i = 2;i <= 3;i++)
temp[6][i][1] = 'X';
for (int i = 5;i <= 6;i++)
temp[6][i][1] = temp[6][i][4] = 'X';
//'7'
for (int i = 2;i <= 3;i++)
temp[7][1][i] = 'X';
for (int i = 2;i <= 3;i++)
temp[7][i][4] = 'X';
for (int i = 5;i <= 6;i++)
temp[7][i][4] = 'X';
//8
for (int i = 2;i <= 3;i++)
temp[8][1][i] = temp[8][4][i] = temp[8][7][i] = 'X';
for (int i = 2;i <= 3;i++)
temp[8][i][1] = temp[8][i][4] = 'X';
for (int i = 5;i <= 6;i++)
temp[8][i][1] = temp[8][i][4] = 'X';
//9
for (int i = 2;i <= 3;i++)
temp[9][1][i] = temp[9][4][i] = temp[9][7][i] = 'X';
for (int i = 2;i <= 3;i++)
temp[9][i][1] = temp[9][i][4] = 'X';
for (int i = 5;i <= 6;i++)
temp[9][i][4] = 'X';
//freopen("F:\rush.txt","r",stdin);
scanf("%d",&T);
while (T--){
for (int i = 1;i <= 7;i++)
scanf("%s",s[i]+1);
int a = get_ans(1,1,7,4),b = get_ans(1,6,7,9);
int c = get_ans(1,13,7,16),d = get_ans(1,18,7,21);
printf("%d%d:%d%d
",a,b,c,d);
}
return 0;
}