前辈们,帮我这个程序注释一下,越详细越好!谢谢!
#include "stdio.h"
#include "string.h"
void main()
{
char str[100];//定义一个长度为100的数组,准备存放即将输入的字符
int i,num=0,w=0;
char c;
gets(str);/*输入一行字符串*/
for(i=0;(c=str[i])!='\0';i++)
//对字符数组中的字符逐个进行判断,看是否为结束字符,若为结束字符,则终止循环
{
if(c==' ')
{
if(w) num++;
w=0;
}
else
{
w=1;
}
}
if(w)
num++;
printf("there are %d word\n",num);
}
它 的主要功能是字母计算器!
#include "stdio.h"
#include "string.h"
void main()
{
char str[100];//定义一个长度为100的数组,准备存放即将输入的字符
int i,num=0,w=0;
char c;
gets(str);/*输入一行字符串*/
for(i=0;(c=str[i])!='\0';i++)
//对字符数组中的字符逐个进行判断,看是否为结束字符,若为结束字符,则终止循环
{
if(c==' ')
{
if(w) num++;
w=0;
}
else
{
w=1;
}
}
if(w)
num++;
printf("there are %d word\n",num);
}
它 的主要功能是字母计算器!





2008-7-7 23:54

