cin>>c && c!='?' 不AC嘞

#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
    char c;
    int letter, digit, others;
    letter = digit = others = 0;
    while(cin>>c&&c!='?'){
        if((c<='z'&&c>='a')||(c<='Z'&&c>='A')) letter++;
        else if(c<='9' && c>='0') digit++;
        else others++;
    }
    cout<<"Letters="<<letter<<endl;
    cout<<"Digits="<<digit<<endl;
    cout<<"Others="<<others<<endl;
    return 0;
}
请问以上代码咋不通过嘞?
while(cin>>c&&c!='?') 和
while((c=getchar())!='?') 有啥差别吗
全部评论
#include<bits/stdc++.h> using namespace std; int main() { string s; getline(cin,s); int f1=0,f2=0; for(int i=0;i<s.size()-1;i++) { if((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z')) f1++; else if(s[i]>='0'&&s[i]<='9') f2++; } cout<<"Letters="<<f1<<endl; cout<<"Digits="<<f2<<endl; cout<<"Others="<<s.size()-1-f1-f2<<endl; return 0; }
点赞 回复 分享
发布于 2020-03-18 10:39
cin不读回车空格之类的字符
点赞 回复 分享
发布于 2020-03-13 11:11

相关推荐

07-02 18:09
门头沟学院 Java
苍穹外卖和谷粒商城这俩是不是烂大街了,还能做吗?
想去重庆的鸽子在吐槽:你不如把这俩做完自己搞明白再优化点再来问 何必贩卖焦虑
点赞 评论 收藏
分享
05-19 19:57
蚌埠学院 Python
2237:Gpa70不算高,建议只写排名,个人技能不在多而在精,缩到8条以内。项目留一个含金量高的,减少间距弄到一页,硕士简历也就一页,本科不要写很多
实习,投递多份简历没人回...
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

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