UVA 621 Secret Research

来源:互联网 发布:windows phone7.8 编辑:程序博客网 时间:2024/05/22 14:52

题目

秘密研究

分析

注意匹配的先后顺序..

代码

#include <stdio.h>#include <string.h>int main(void){    int t;    char s[5000];    scanf("%d", &t);    while (t--) {        scanf("%s", s);        if (!strcmp(s, "1") || !strcmp(s, "4") || !strcmp(s, "78"))            printf("+\n");        else if (s[strlen(s) - 2] == '3' && s[strlen(s) - 1] == '5')            printf("-\n");        else if (s[0] == '9' && s[strlen(s) - 1] == '4')            printf("*\n");        else if (s[0] == '1' && s[1] == '9' && s[2] == '0')            printf("?\n");    }    return 0;}
0 0
原创粉丝点击