3个回答
展开全部
#include <stdio.h>
void main()
{
char ch;
int digit = 0,letter= 0, other= 0, black = 0;
printf("Please enter a Line String:/n");
while ((ch = getchar()) != '\n') //输入一行字符,以回车换行符结束
{
if ((ch>='a' && ch<='z') || (ch>='A' && ch<='Z')) //字母判断条件
letter++;
else if(ch>='0' && ch<='9') //数字条件判断
digit++;
else if(ch==' ')
black++;
else
other++;
}
//输出结果
printf("字母:%d\n数字:%d\n空格:%d\n其他:%d\n",letter,digit,black,other);
}
void main()
{
char ch;
int digit = 0,letter= 0, other= 0, black = 0;
printf("Please enter a Line String:/n");
while ((ch = getchar()) != '\n') //输入一行字符,以回车换行符结束
{
if ((ch>='a' && ch<='z') || (ch>='A' && ch<='Z')) //字母判断条件
letter++;
else if(ch>='0' && ch<='9') //数字条件判断
digit++;
else if(ch==' ')
black++;
else
other++;
}
//输出结果
printf("字母:%d\n数字:%d\n空格:%d\n其他:%d\n",letter,digit,black,other);
}
来自:求助得到的回答
2012-11-21
展开全部
#include <stdio.h>
int main()
{
char a;
int number = 0;
int word = 0;
int nelse = 0;
int black = 0;
while ((a = getchar()) != '\n')
{
if ((a>='a' && a<='z') || (a>='A' && a<='Z'))
{
word++;
}
else if(a>='0' && a<='9')
{
number++;
}
else if(a==' ')
{
black++;
}
else
{
++nelse;
}
}
printf("字母:%d\n数字:%d\n空格:%d\n其他:%d\n",word,number,black,nelse);
}
int main()
{
char a;
int number = 0;
int word = 0;
int nelse = 0;
int black = 0;
while ((a = getchar()) != '\n')
{
if ((a>='a' && a<='z') || (a>='A' && a<='Z'))
{
word++;
}
else if(a>='0' && a<='9')
{
number++;
}
else if(a==' ')
{
black++;
}
else
{
++nelse;
}
}
printf("字母:%d\n数字:%d\n空格:%d\n其他:%d\n",word,number,black,nelse);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include "stdio.h"
#include <math.h>
#include <stdlib.h>
int main()
{
int a=0,b=0,c=0,d=0;
char ch;
while((ch=getchar())!='\n')
{
if(ch>='A'&&ch<='Z'||ch>='a'&&ch<='z')
a++;
else if(ch>='0'&&ch<'9')
b++;
else if(ch==' ')
c++;
else
d++;
}
printf("%d %d %d %d",a,b,c,d);
return 0;
}
#include <math.h>
#include <stdlib.h>
int main()
{
int a=0,b=0,c=0,d=0;
char ch;
while((ch=getchar())!='\n')
{
if(ch>='A'&&ch<='Z'||ch>='a'&&ch<='z')
a++;
else if(ch>='0'&&ch<'9')
b++;
else if(ch==' ')
c++;
else
d++;
}
printf("%d %d %d %d",a,b,c,d);
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询