遇到好多次了,为什么VS中自测完全正常,牛客上却出错呢?
如下的题:
#include<iostream>
#include<string>using namespace std;
int main()
{
string s;
int alpha_cnt = 0, num_cnt = 0, space_cnt = 0, other_cnt = 0;
while (getline(cin, s)) {
for (size_t i = 0;i < s.size();++i) {
if (isalpha(s[i]))
++alpha_cnt;
else if (isdigit(s[i]))
++num_cnt;
else if (isspace(s[i]))
++space_cnt;
else
++other_cnt;
}
cout << alpha_cnt << endl;
cout << space_cnt << endl;
cout << num_cnt << endl;
cout << other_cnt << endl;
}
return 0;
}
#笔试题目#