c语言 程序 谁帮我改改

来源:百度知道 编辑:UC知道 时间:2024/06/25 03:41:56
#include<stdio.h>
void main()
int letter, digit, space, others;
main()
{ int count( char str[]);
char text[80];
printf("\n Input string: \n");
gets(text);
printf("string:");
puts(text);
letter=0;
digit=0;
space=0;
others=0;
count(text);
printf(" letter=%d, digit=%d, space=%d, others=%d\n",letter, digit, space, others);
}

int count( char str[])
{ int i;
for (i=0; str[i] != '\0'; i++)
if ((str[i]>='a' && str[i]<='z') || (str[i]>='A' && str[i]<='Z'))
letter++;
else if ((str[i]>='0' && str[i]<='9'))
digit++;
else if (strcmp(str[i], ' ')==0)
space++;
else
others++;
}

#include<stdio.h>

int letter, digit, space, others;

void main()
{
void count( char str[]);
char text[80];
printf("\n Input string: \n");
gets(text);
printf("string:");
puts(text);
letter=0;
digit=0;
space=0;
others=0;
count(text);
printf(" letter=%d, digit=%d, space=%d, others=%d\n",letter, digit, space, others);
}

void count( char str[])
{
int i;
for (i=0; str[i] != '\0'; i++)
if ((str[i]>='a' && str[i]<='z') || (str[i]>='A' && str[i]<='Z'))
letter++;
else if ((str[i]>='0' && str[i]<='9'))
digit++;
else if (str[i] == ' ')
space++;
else
others++;
}

其实程序没什么大问题,可能是楼主疏忽吧, mian函数是不需要声明的 所以第一句void main() 就不用了

#include<stdio.h>