遇到好多次了,为什么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;
}
#笔试题目#
全部评论
你忘了把变量归零。这是个循环。
点赞 回复 分享
发布于 2018-10-03 23:41
点赞 回复 分享
发布于 2018-10-03 21:01

相关推荐

积极的小学生不要香菜:你才沟通多少,没500不要说难
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务