18 条题解

  • 0
    @ 2026-5-23 10:08:21

    #include<bits/stdc++.h> using namespace std ; int main ( ) { char ch ;//每次读一个字符 int len = 0 ;//统计单词的长度 bool f = 1 ;//判断是不是第一个输出(1是真,0是假) while ( cin.get(ch) ) { if ( ch == ' ' ) { if ( len > 0 ) { if ( f == 1 ) { cout << len ; f = 0 ; } else { cout << "," << len ; } len = 0 ; } } else { len ++ ; } } if ( len > 0 ) { if ( !f ) { cout << "," ; } cout << len ; } return 0 ;
    }

    信息

    ID
    1095
    时间
    1000ms
    内存
    128MiB
    难度
    6
    标签
    递交数
    1045
    已通过
    353
    上传者