Uva 621 Secret Research

80 阅读1分钟

题意:

对于给出的数字判断是四种类型的哪一种,其实很简单因为s就三种情况,所有输入枚举的话也就12种。

#include<iostream>
#include<cstring>
using namespace std;
char s[15];
int n;
int ju(int i){
	if(s[i]=='1'||s[i]=='4'||(s[i]=='7'&&s[i+1]=='8'))
	return 1;
	else return 0;
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%s",s);
		n=strlen(s);
		if((n==1||n==2)&&ju(0)) puts("+");
		else if(s[n-2]=='3'&&s[n-1]=='5'&&ju(0)) puts("-");
		else if(s[0]=='9'&&s[n-1]=='4'&&ju(1)) puts("*");
		else puts("?");
	}
	return 0;
} 


\