c语言 问题 急求答案 自己先调试

来源:百度知道 编辑:UC知道 时间:2024/05/25 11:57:43
~~~~~~~~~~输入一行字符分别统计出英文字母,空格,数字,和其他字符的个数。并输出结果。~~~~~~~~~
上面的问题给出答案时并写出注释
谢谢

#include "stdio.h"
void main()
{
static int i,abc,space,number,other;
char str[100];
printf("please input the string:\n");
gets(str);

for(i=0;str[i]!='\0';i++)
{
if(str[i]>='a'&&str[i]<='z' || str[i]>='A'&&str[i]<='Z') //字符
abc++;
else if(str[i]==' ') //空格
space++;
else if(str[i]>='0'&&str[i]<='9') //数字
number++;
else //其他字符
other++;
}

printf("char is %d\nspace is %d\nnumber is %d\nother is %d\n",abc,space,number,other);
}

#include<stdio.h>
int main()
{
int i,j,count[5]={0};
char arrow[3][81];
printf("Please input Article:\n");
for(i=0;i<3;i++)
gets(arrow[i]);
for(i=0;i<3;i++) /*对每一行进行统计*/
for(j=0;j<=80&&arrow[i][j]!='\0';j++)
{