c语言问题,急~!

来源:百度知道 编辑:UC知道 时间:2024/05/22 20:42:03
从键盘输入一系列字符,包括数字,空格和其他字符,当输入数字1时程序结束,最后分别计算输入的数字,空格和其他字符的个数,请给出完整程序,谢谢~!

#include "conio.h"
#include "stdio.h"
void main()
{
char c;
int Count[]={0,0,0,0,0},i=0;
printf("Input the archive:\n");
do
{
c=getche();

if(c>='a'&&c<='z') Count[0]++;
else if(c>='A'&&c<='Z') Count[1]++;
else if(c==' ') Count[2]++;
else if(c>='0'&&c<='9') Count[3]++;
else Count[4]++;
i++;
if(i>=10) {printf("\n");i=0;}/*用来控制输入格式,10个一行方便检查*/
}while(c!='1');
printf("\na~z:%d A~Z:%d space:%d Number:%d Other:%d",Count[0],Count[1],Count[2],Count[3],Count[4]);
}

程序通过编译、运行,完全正确。

#include "stdio.h"

void main()
{
char c;
int m=0;

p: scanf("%c", &c);
if (c != '1')
{
m++;
goto p;