虽然是水题, 但我看了几遍题目还是看不懂. 英语捉急了.
题意是让你按题目上的顺序匹配, 比如说输入的后两位是35, 对应的就是negative result.以此类推.
不过这句话我一直没看懂
(A sample result S35 means that if we add digits 35 from the right hand side to a digit sequence then we shall get the digit sequence corresponding to a failed experiment)
他的意思是要从字符串的右方开始匹配吗? 那后面的那个corresponding to a failed experiment 是怎么回事...
事实上题目确实是按字符串的右方开始匹配的. 比如19035, 对应的是S35, 而不是190S.
--------------------------------------4.20补充---------------------------------------
感谢@buxizhizhou530提醒, 上面那句话的意思是S35意味着,假设S是原来失败的实验的序列,那么把35放在S的最右边,则得到的序列是对应于该实验的加密序列。这样一来匹配的问题就可以解释了. 按题目给的顺序匹配下来即可.
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
//freopen("input.txt", "r", stdin);
char s[10001];
memset(s, 0, sizeof(s));
int n;
scanf("%d", &n);
getchar();
while (n--)
{
gets(s);
int len = strlen(s);
if (s[len - 1] == '5')
printf("-\n");
else if (s[0] == '9')
printf("*\n");
else if (s[0] == '1' && len > 1)
printf("?\n");
else
printf("+\n");
}
return 0;
}