小白求解,课本代码。

2301_81141171 2301_81141171 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

#include<stdio.h>
#include<stdlib.h>
int main()
{
    char str[81];
    int i=0,num=0,word=0;
    char c;
    while((str[i++]=getchar())!='\n');
    str[i]='\0';                \\就这边str[i++]不是回车,则都为\0,而下面循坏的条件是str[i]不等于\0,就这里搞不清楚
    for(i=0;(c=str[i])!='\0';i++)
        if(c==' ')word=0;
        else if(word==0)
        {
            word=1;
            num++;
        }
        printf("%d\n",num);
        system("pause");
        return 0;

}

...全文
评论 3
收藏 已收藏
分享
返回顶部
2301_81141171
C语言 70,040 成员 243,237 内容