Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
118965 李昊宇 31单词的长度 C++ Accepted 0 MS 276 KB 380 2025-05-11 14:45:35

Tests(5/5):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ string s; int t=0; getline(cin,s); int len = s.size(); for(int i=0;i<len;i++){ if(s[i]!=' '){ //这个位置不是空格。 t++; } else if(s[i]==' '&&t != 0){ cout<<t<<","; t = 0; } if(i==len-1 && t!=0){ //到达最后一个字符,要输出 cout<<t; } } return 0; }