//抄的书上的统计单词数的代码
AC代码:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30#include<iostream> #include<cmath> #include<iomanip> #include<string> #include<bits/stdc++.h> using namespace std; int main() { char sentence[60]; int n = 0; cin >> n; getchar(); while (gets(sentence), n--) { char prev = ' '; int cnt = 0; for (int i = 0; sentence[i] != ''; i++) { if (sentence[i] != ' '&&prev == ' ') { cnt++; } prev = sentence[i]; } cout << cnt << endl; } //system("pause"); return 0; }
输入一行字符,用函数编程统计其中有多少单词。
最后
以上就是笑点低画笔最近收集整理的关于东华大学 2022 oj c++ 无超纲写法 单词统计的全部内容,更多相关东华大学内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复