标题:谁来帮我吧FOR改成while
取消只看楼主
hedy704
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2010-7-23
结帖率:100%
 问题点数:0 回复次数:1 
谁来帮我吧FOR改成while
程序代码:
for(i=0;(c=str[i])!='\0';i++)
        if(c==' ')word=0;
        else if(word==0)
        {
            word=1;
            num++;
        }
        printf("There are %d words in the line.\n",num);
谁来帮我吧FOR改成while
搜索更多相关主题的帖子: FOR 
2010-07-25 14:41
hedy704
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2010-7-23
得分:0 
i=0;
while((c=str[i])!='\0')
{      
        if(c==' ')word=0;
        else if(word==0)
        {
            word=1;
            num++;
        }
       i++;
}
printf("There are %d words in the line.\n",num);
这样行不?
2010-07-25 15:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-313935-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.044715 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved