UVA621-秘密研究

#include <iostream>
#include <string>
using namespace std;
int main ()
{
//    string a[3] = {"135","435","7835"};
//    string b[3] = {"914","944","9784"};
//    string c[3] = {"1901","1904","19078"};
//    string d[3] = {"1","4","78"};
    string s;
    int n;
    cin>>n;cin.get();
    while(n--)
    {
        getline(cin,s);
        int flag = 1;
        for(int i = 0; i < 3; i++)
        {
            if(s=="78"||s=="4"||s == "1")
            {
                cout<<"+"<<endl;
                flag = 0;
                break;
            }
            else if(s[s.size()-2]=='3'&&s[s.size()-1]=='5')
            {
                cout<<"-"<<endl;
                flag = 0;
                break;
            }
            else if(s[0]=='9'&&s[s.size()-1]=='4')
            {
                cout<<"*"<<endl;
                flag = 0;
                break;
            }
            else if(s[0]=='1'&&s[1]=='9'&&s[2]=='0')
            {
                cout<<"?"<<endl;
                flag = 0;
                break;
            }

        }
        if(flag)cout<<"+"<<endl;
    }
    return 0;
}
水题,判字符串
唯一需要注意的是+-*?的先来后到,

posted on 2012-08-21 10:21  Primo...  阅读(111)  评论(0编辑  收藏  举报