【牛客】牛客小白月赛2 C题(对string[]的操作)

C   真真假假 

https://www.nowcoder.com/acm/contest/86/C

算卦先生来问你,对于每个他给出的 C++ 头文件,请告诉他是否存在。
头文件列表:algorithm, bitset, cctype, cerrno, clocale, cmath, complex, cstdio, cstdlib, cstring, ctime, deque, exception, fstream, functional, limits, list, map, iomanip, ios, iosfwd, iostream, istream, ostream, queue, set, sstream, stack, stdexcept, streambuf, string, utility, vector, cwchar, cwctype
 
思路:建立string[]数组,把这些都存进去,判断的时候for里的条件可以写成 for(int i=0;str[i].size();i++)
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
 
const int MAX_N=1005;
int n,T;
LL a[MAX_N];
string str[100]={
"algorithm", "bitset", "cctype", "cerrno", "clocale","cmath" , "complex","cstdio", "cstdlib",
"cstring", "ctime", "deque", "exception", "fstream", "functional", "limits", "list",
 "map", "iomanip", "ios", "iosfwd","iostream" , "istream", "ostream", "queue", "set",
 "sstream", "stack","stdexcept" , "streambuf", "string", "utility", "vector", "cwchar", "cwctype"};
 
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    string ans="Kun",ss;
    for(int i=0;i<n;++i)
    {
        cin>>ss;
        ans="Kun";
        for(int i=0;str[i].size();++i)
            if(str[i]==ss){
                ans="Qian"; break;
            }
        cout<<ans<<endl;
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/Kohinur/p/8908789.html