#include<stdio.h>
#include<conio.h>
main()
printf("请输入一串数字\n");
{
char c;
int letter=0,space=0,digital=0,others=0;
while((c=getchar())!='\n')
{
if ((c>='a'&&c<='z')||c>='A'&&c<='Z')
letter++;
else if (c==' ')
space++;
else if (c>='0'&&c<='9')
digital++;
else
others++;
}
printf("letter=%d\n space=%d\n digital=%d\n others=%d",letter,space,digital,others);
getch();
}
就是这个程序,第四行printf加上就出错,不加就不出错。程序意思是输入一段字母数字,判断其中数字,字母,空格,其他字符各有几个。求帮助!谢谢
#include<conio.h>
main()
printf("请输入一串数字\n");
{
char c;
int letter=0,space=0,digital=0,others=0;
while((c=getchar())!='\n')
{
if ((c>='a'&&c<='z')||c>='A'&&c<='Z')
letter++;
else if (c==' ')
space++;
else if (c>='0'&&c<='9')
digital++;
else
others++;
}
printf("letter=%d\n space=%d\n digital=%d\n others=%d",letter,space,digital,others);
getch();
}
就是这个程序,第四行printf加上就出错,不加就不出错。程序意思是输入一段字母数字,判断其中数字,字母,空格,其他字符各有几个。求帮助!谢谢