文章

75

粉丝

0

获赞

153

访问

8.9k

头像
统计单词 题解:c++
P1394 华中科技大学机试题
发布于2026年2月8日 14:36
阅读数 236

#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    string s ;
    while(getline(cin,s)){
        int temp = 0;
        for(int i = 0 ; i < s.size() ; i++){       
            if(s[i] != ' ' && s[i] != '.') temp++;    //判断结尾 ,进行单词字母 统计
            else{
                if(temp){
                    cout << temp << " ";
                    temp = 0;
                }
            }
        }
        cout << endl;
    }
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发