听取wa声一片

B2120 单词的长度

yjx0213 @ 2024-08-01 20:03:28

a=input() b=a.count(',') a=a.replace(',',' ',b) b=a.count('.') a=a.replace('.',' ',b) a=list(a.split()) c=[] for i in a: i=str(i) d=len(i) c.append(d) c[len(c)-1]+=1 print(c)


by xzgy @ 2024-08-29 17:53:43

@yjx0213

#include<bits/stdc++.h>
using namespace std;
int main() {
    int a=1;
    string n;
    while(cin>>n){
        if(a==1)cout<<n.size();
        else cout<<","<<n.size();
        a++;
    }
    return 0;
}

|