题目大意
给你 个长度为 的字符串,每一个字符都是一个 LED 管,问对于每个字符串是否能只构成一个数字。
题目分析
- 首先对 到 的 LED 状态进行预处理。
- 输入。
- 一个数字一个数字比对过去,加号减号不用管,如果发现有不一样的就跳过,如果从头到尾都一样计数变量加 ,并且将答案保存下来。
- 看看计数变量等于几,如果是 ,就输出答案,如果不是 ,就输出星号。
#include <bits/stdc++.h>
using namespace std;
string led[10] = {"GGGgGGG","gggggGG","gGGGGGg","ggGGGGG","GggGgGG","GgGGGgG", "GGGGGgG","ggGggGG","GGGGGGG","GgGGGGG"};
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int n;
cin >> n;
while (n--){
string s;
cin >> s;
int cnt = 0,ans;
for (int i = 0;i < 10;i++){
bool flag = true;
for (int j = 0;j < 7;j++){
if (!(s[j] == led[i][j] or s[j] == '+' or s[j] == '-')) flag = false;
}
if (flag){
cnt++;
ans = i;
}
}
if (cnt == 1) cout << ans;
else cout << '*';
}
return 0;
}