c语言入门问题,求大神解答俶

2025-04-26 09:56:59
推荐回答(4个)
回答1:

#include


void main()

{

char ch;

int a;

ch=getchar();

if(ch>='a'&&ch<='z')

ch='1';

if(ch>='A'&&ch<='Z')

ch='2';

if(ch==' ')

ch='3';

switch(ch)

{

case'1':

printf("小写字母\n");

break;

case'2':

printf("大写字母\n");

break;

case'3':

printf("空格\n");

break;

default:

printf("其他");

}

}

回答2:

您好,很高兴回答您的问题。

对于您说的问题,确实是属于入门级别的问题,您要多多自己动手操作哦。而且switch 语句是有很多的限制条件的,个人认为不是很适合在您所说的这个题目中。建议用if-else语句很容易解决您说的问题,switch语句反而把问题弄复杂了。

回答3:

系语言入门问题,这是专业的电脑知识,你必须认真的学习才能提高自己的领会能力。

回答4:

#include
void main()
{
char ch;
printf("Please input a character : \n");
ch=getchar();
ch= ch=32 || ch>=48 && ch<=57 || ch>=65 && ch<=90 || ch>=97 && ch<=122 ? ch/5 : -6;
switch (ch)
{
case 6: printf ("This is a blank space character!\n");break;
case 9:
case 10:
case 11: printf ("This is a number!\n");break;
case 13:
case 14:
case 15:
case 16:
case 17:
case 18: printf ("This is a capital letter!\n");break;
case 19:
case 20:
case 21:
case 22:
case 23:
case 24: printf ("This is a lowercase letter!\n");break;
default:printf("This is a other character!\n");
}
}
//用ASCLL码来做这道题