#include<iostream> using namespace std; int main() { char word[100]; int count=0,i=0; cin.getline(word,100); while(word[i]!='\0') { if(word[i]>='a'&&word[i]<='z'||word[i]>='A'&&word[i]<='Z') count++; i++; } cout<<count<<endl; return 0; }
刚开始接触C++,欢迎大家批评指正!!
0.0分
2 人评分
#include<stdio.h> #include<iostream> using namespace std; int main(){ char a; int temp=0; while((a=getchar())!='\0') { if(a>=65&&a<=90||a>=97&&a<=122) { temp++; } } cout<<temp; } 这个为什么超时了,求解
余小C 2020-03-02 21:48:36 |
a=getchar())!=' ',a不是True就False(0). 要分开写哦