文章

15

粉丝

0

获赞

25

访问

1.5k

头像
统计单词 题解:句号前有空格
P1394 华中科技大学机试题
发布于2026年2月5日 21:03
阅读数 149

#include <iostream> 
#include <string>
#include <cctype>
using namespace std;

int main() {
    string str;
    int cnt;
    while(cin >> str) {
        if(str.size() == 1 && str[0] == '.') continue; //不加这句只过80%
        cnt = 0;
        for(int i = 0; i < str.size(); i++) 
            if(islower(str[i]) || isupper(str[i])) cnt++;
        cout << cnt << ' ';
    }
    return 0;    
}

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发