文章

9

粉丝

56

获赞

0

访问

2.4k

头像
统计单词 题解:通过率只有80%,求大佬指点一下哪里错了
P1394 华中科技大学
发布于2024年3月9日 13:38
阅读数 268

#include<stdio.h>
#include<string.h>
int main(){
    char string[105];
    while(gets(string)){
        int cnt=0;
        //用于记录是否是遇到的收个空格 
        int flag=0; 
        //用于记录遇到的单词的字符个数 
        int ind=0;
        int arr[105]={0};
        //当前元素不是.就继续循环 
        while(string[cnt]!='.'){
            //若遇到空格 
            if(string[cnt]==' '){
                //遇到的第一个空格时,将ind++,flag=1,若后续在遇到空格时候不在进行ind++;直到遇到下个单词
                if(flag==0){
&n...

登录查看完整内容


登录后发布评论

2 条评论
snake
2024年3月9日 15:21

输出的时候判断一下,arr[i]如果>0才输出

赞(0)

18237466773 : 回复 snake: 解决了!,谢谢大佬!!

2024年3月9日 15:57