首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
huangdashuaige
2023年2月20日 13:12
P1394 统计单词
P1394
回复 0
|
赞 0
|
浏览 3.3k
#include <iostream> using namespace std; int main(){ int i,m,n[100]; //i用于记录输入字符遍历的位置,m用于记录总共有几个单词,n数组表述各个单词长度 for(int j=0;j<100;j++) n[j]=0;//初始化数组n i=m=0; char s[100];//记录输入字符 &...
gallopzhang
2022年8月9日 23:43
简单思维的解法
P1394
回复 0
|
赞 1
|
浏览 4.8k
直接从前向后扫描,判断字符关系 #include <bits/stdc++.h> using namespace std; int main() { char a[105]; while(gets(a)) { int len = strlen(a); int count = 0;  ...
Dear_Mr_He
2021年11月18日 11:25
就挺离谱的。。
P1394
回复 1
|
赞 8
|
浏览 8.8k
这题不难,就是有些奇奇怪怪坑人的地方。。。 #include<stdio.h> #include<string.h> int main() { char s[10]; while (scanf("%s", s) != EOF) { // 注意:这里一定要加上“!=EOF”,去掉的话在本机编译器调试没问题,但是评测会出问题,就很离谱,大家可以试试 int len = strlen(s); if (s[0] == '.') continue; // 这里要注意一个特殊情况,就是有样例在结束标志“.”前多了个空格,所...
li_yi
2022年2月3日 14:21
小白,代码拙劣
P1394
回复 0
|
赞 1
|
浏览 5.2k
#include #include char a[100]; int main(){ while(gets(a)){ int count=0; int len=strlen(a); for(int i=0;i='A' && a[i]<='Z') || (a[i]>='a' && a[i]<='z')) count++; if(a[i]==32...
杨德胜
2021年3月7日 13:36
P1394 解题思路分享
P1394
回复 0
|
赞 0
|
浏览 8.6k
#include <bits/stdc++.h> using namespace std; int main() { char s[105]={0}; while(cin>>s){ int len=strlen(s); if(s[len-1]=='.') len--; if(len!=0) cout <<len<<' '; } }
鱼翔浅底
2021年1月17日 21:08
考虑多个空格的情况
P1394
回复 0
|
赞 1
|
浏览 9.7k
#include <stdio.h> #include <string.h> #include <stdlib.h> int main() { char s[1000]; int cnt=0; while (gets(s)) { for (int i = 0; s[i] != '\0'; i++) { if ((s[i]==' '||s[i]=='.')&&cnt!=0) { ...
老猫
2021年1月12日 15:16
记录
P1394
回复 0
|
赞 0
|
浏览 9.1k
#include <bits/stdc++.h> using namespace std; int main() { char s[300]; while(gets(s)) { int len=strlen(s); int cnt=0; for(int i=0;i<len;i++) { if(s[i]==' '||s[i]=='.') { if(cnt!=0) printf("%d ",cnt); cnt=0; if(s[i]=='.') break; ...
tyu007
2020年3月19日 23:01
1349(个人记录)
P1394
回复 3
|
赞 0
|
浏览 13.6k
#include<iostream> #include<string> using namespace std; int main() { string s; while(getline(cin,s)) { int l=s.size(); int k=0; for(int i=0;i<l;i++) { //此题之前未考虑到位的点在于,漏洞可能吧标点符号等读入 if(s[i]>='a'&&s[i]<='z'...
fanxi
2020年5月10日 21:30
模板题
P1394
回复 0
|
赞 0
|
浏览 10.5k
由于能ac,所以题目的测试数据应该没有类似it's这种,如果下次有的话,把s[i]>='a'&&s[i]<='z'换成s[i]!=' '就好了 #include <stdio.h> #include <string.h> int main() { char s[10000]; while(gets(s)) { int len=strlen(s); int count[10000]={0},cnt=0;...
all-clear
2020年4月26日 13:12
好坑的输入
P1394
回复 0
|
赞 0
|
浏览 9.9k
#include<cstdio> #include<cstring> using namespace std; int main() { char str[5000]; while(scanf("%c",&str[0])!=EOF) { gets(str+1); int num=0; for(int i=0;i<strlen(str);i++) { char c = str[i]; switch(c) { case ' ':if(num) printf("%d ",n...
1
2
3
4
5
题目
统计单词
题解数量
41
发布题解
在线答疑
热门题解
1
纯纯逆天测试例(‘.'前有可能是空格)
2
统计单词 题解:写出这么简单的代码也是神人了
3
统计单词 题解:
4
统计单词(C++) 题解:
5
统计单词 题解:可过,判断条件很简单
6
统计单词 题解:
7
统计单词 题解:测试用例只有一个坑,别的很基本
8
就挺离谱的。。
9
统计单词 题解:
10
统计单词 题解: