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

相关推荐

怼怼高:我想问一下其他软件都是自己学的吗,我们学校只学了ps ai诶
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
09-04 12:35
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

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