Secret Research
At a certain laboratory results of secret research are thoroughly encrypted. A result of a single experiment is stored as an information of its completion:
`positive result’, `negative result’, `experiment failed’ or `experiment not completed’
he encrypted result constitutes a string of digits S, which may take one of the following forms:
$\bullet$ positive result S = 1 or S = 4 or S = 78 $\bullet$ negative result S = S35 $\bullet$ experiment failed S = 9S4 $\bullet$ experiment not completed S = 190S
(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)
You are to write a program which decrypts given sequences of digits.
Input
A integer n stating the number of encrypted results and then consecutive n lines, each containing a sequence of digits given as ASCII strings.
Output
For each analysed sequence of digits the following lines should be sent to output (in separate lines):
+ for a positive result - for a negative result * for a failed experiment ? for a not completed experiment
In case the analysed string does not determine the experiment result, a first match from the above list should be outputted.
Sample Input
4 78 7835 19078 944
Sample Output
+ - ? *
C Code
#include<stdio.h>
#include<string.h>
#define MAXN 10000
char S[MAXN];
int Pos() {
if(!strcmp(S,"1")) return 1;
else if(!strcmp(S,"4")) return 1;
else if(!strcmp(S,"78")) return 1;
return 0;
}
int Neg() {
int l = strlen(S);
if(l<3) return 0;
if(S[l-1] == '5' && S[l-2] == '3') return 1;
return 0;
}
int Fail() {
int l = strlen(S);
if(l<3) return 0;
if(S[0] == '9' && S[l-1] == '4') return 1;
return 0;
}
int Incom() {
int l = strlen(S);
if(l<4) return 0;
if(S[0] == '1' && S[1] == '9' && S[2] == '0') return 1;
return 0;
}
void Cal() {
if(Pos()) { printf("+\n"); return; }
else if(Neg()) { printf("-\n"); return; }
else if(Fail()) { printf("*\n"); return; }
else if(Incom()) { printf("?\n"); return; }
}
void main() {
int n;
scanf("%d",&n);
while(n -- ) {
scanf("%s",S);
Cal();
}
}