Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
7621 邓小龙 单词的长度 C++ Accepted 0 MS 264 KB 537 2025-05-10 10:10:08

Tests(5/5):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ //思路:遍历整句话,每遇到一个非空格的字符cnt++ //如果遇到空格,那么输出cnt,并且cnt=0 char ch[1010]; int cnt=0, n; cin.getline(ch,1000); //cout<<ch<<endl; n=strlen(ch); for(int i=0;i<n;i++){ if(ch[i]!=' ') cnt++; else{ if(cnt!=0){ cout<<cnt<<','; cnt=0; } } } if(cnt!=0) cout<<cnt; return 0; }