首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
huanghu
2024年3月8日 16:04
统计单词 题解:c++
P1394
回复 0
|
赞 1
|
浏览 907
#include<stdio.h> #include<iostream> #include<string> using namespace std; int main(){ string str; while(getline(cin,str,'.')){ int len = str.length(); int count = 0; for(int i = 0; i<len; i++){ i...
799
2024年3月6日 16:55
统计单词 题解:
P1394
回复 0
|
赞 0
|
浏览 604
#include <bits/stdc++.h> using namespace std; char s[105]; int main() { /* 思想: 1、利用一个标识符 来统计每个单词字符的个数cnt 2、多个空格时,就看前一位是否为字母 3、遇到字母+'.'结束打印 4、i=0 or 空格+字母:开始计数cnt=1;字母+字母cnt++ &nbs...
williams
2024年3月6日 13:42
统计单词 题解:c 注意分类讨论
P1394
回复 0
|
赞 1
|
浏览 601
#include <stdio.h> #include <stdbool.h> #include <math.h> #include <string.h> int main(void) { char s[1000]; int count; while (gets(s)!=NULL) { for(int i=0;i<strlen(s);i++){ if(s[i]=='.'&&(s[i-1]>='a'&&s[i-...
promising
2024年3月5日 21:12
统计单词 题解:
P1394
回复 2
|
赞 0
|
浏览 846
这个方法看起来很简单,但是if语句那块没看懂,不懂为啥count是每个单词的字母个数,有没有大佬能解答一下 #include<stdio.h> #include<string.h> int main() { char temp[100]; while (scanf("%s", temp) != EOF)//C语言中,EOF常被作为文件结束的标志 { &...
orderrr
2024年2月24日 22:11
统计单词 题解:
P1394
回复 0
|
赞 1
|
浏览 826
/* 思想: 1、利用一个标识符 来统计每个单词字符的个数 2、多个空格时,就利用标识符来判断是不是连续的空格 */ #include <bits/stdc++.h> using namespace std; int main() { char c[1000]; while (fgets(c, 1000, stdin)) { int judge = 0; for (int i = 0; i < 100, c[i] != '\n'; i++) { ...
carrot_huan
2024年2月7日 17:08
统计单词 题解:
P1394
回复 0
|
赞 0
|
浏览 1.2k
#include<bits/stdc++.h> using namespace std; int main() { string str; while (getline(cin, str)) { int count = 0; for (int i = 0; i < str.size()&...
孙某人
2024年1月17日 22:13
统计单词 题解:易错点
P1394
回复 0
|
赞 2
|
浏览 1.3k
#include<iostream> #include <string.h> #include <stdio.h> using namespace std; int main(){ char a[10000]; char c[10000]; int b[10000]; int cc=0; while(1){ cc=0; for(int i=0;i<10000;i++){//初始化(也可以 while(gets(c))) b[i]=0; a[i]=0; c[i]=0; } gets(c); for(int i=...
dongqing
2023年7月30日 17:43
统计单词 题解:
P1394
回复 0
|
赞 1
|
浏览 1.1k
注意 整行包括空格输入采用getline 多组输入 while 注意空格和.双重判断 如果碰到空格则输出并且重新统计,不是空格则累加 #include<bits/stdc++.h> using namespace std; int main(){ string s; while(getline(cin,s)) { int cnt=0; for(int i=0;i<s.size();i++) { i...
阔赛英
2023年2月1日 16:01
三种情况:读取到字母、代表单词结束的空格、连续的空格
P1394
回复 4
|
赞 3
|
浏览 4.7k
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int main() { char s[128]; while (gets(s)) { int len = strlen(s); int count = 0; for (int i = 0; i < len; i++) {//遍历字符串 if ((s[i] == ' ' ...
Hegel
2023年3月22日 16:21
统计一串字符内的各个单词长度
P1394
回复 0
|
赞 0
|
浏览 2.5k
注: 这串字符内有空格,必须使用getline(cin,s) #include <iostream> #include <string> using namespace std; int main() { string s; while(getline(cin,s)){ int flag=0; string temp=""; for(int i=0;i<s.size();i++){ if((s[i]>='a'&&s[i]<='z')||s[i]>='A'&&am...
1
2
3
4
5
题目
统计单词
题解数量
41
发布题解
在线答疑
热门题解
1
纯纯逆天测试例(‘.'前有可能是空格)
2
统计单词 题解:写出这么简单的代码也是神人了
3
统计单词 题解:
4
统计单词(C++) 题解:
5
统计单词 题解:可过,判断条件很简单
6
统计单词 题解:
7
统计单词 题解:测试用例只有一个坑,别的很基本
8
就挺离谱的。。
9
统计单词 题解:
10
统计单词 题解: