PAGE 1
21.htm
01. 从键盘输入一个字符,如果是大写字母,就转换成小写;如果是
小写字母,就转换成大写,如果是其他字符原样保持并将结果输出。
#include
void main()
{ char c;
scanf("%c",&c);
if(c>='A'&&c<='Z') c=c+32;
else if(c>='a'&&c<='z') c=c-32;
printf("%c",c);
}
02. 从键盘输入一个数,判断其是否是 5 的倍数而不是 7 的倍数。如
果是,输出 Yes,否则输出 No。
#include
void main()
{ int a;
scanf("%d",&a);
if(a%5==0&&a%7!=0) printf("yes");
else printf("no");
}
03. 从键盘输入一个 4 位正整数,求其逆序数,并输出。例如:若输
入 1234,则输出应该是 4321。
#include
void main()
{ int n,g,s,b,q,m;
scanf("%d",&n);
q=n/1000; b=n/100%10; s=n/10%10; g=n%10;
m=g*1000+s*100+b*10+q;
printf("%d\n",m);
}
22.htm
01. 从键盘输入一个字符,如果是字母,就输出其对应的
如果是数字字符,就转换成对应整数并输出。
ASCII 码;
#include
void main()
{ char c;
scanf("%c",&c);
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
printf("ASCII:%d",c);
else if(c>='0'&&c<='9') printf(" 数字:%d",c-'0');
}
02. 从键盘输入一个数,判断其是否能同时被 3 和 5 整除。如果是,
若输入 2523,则输出应该是 60。
(-10
(0<=x<10)
(x>=10)
2x
x2
#include
void main()
{
int x,y;
scanf( “% d”,&x);
if (x>-10 && x<0 )
y=x+10;
y=2*x;
else if (x<10)
else y=x*x;
printf( “x=%d,y=%dn ”,x,y);
}
02. 从键盘输入一个数,判断其是否是 5 的倍数而不是 7 的倍数。如
果是,输出 Yes,否则输出 No。
#include
void main()
{ int a;
scanf("%d",&a);
if(a%5==0&&a%7!=0) printf("yes");
else printf("no");
}
03. 从键盘输入一个五位整数,判断它是不是对称数,并输出判断结
果。如 43234就是对称数。
#include
void main()
{ int n,g,s,b,q,w;
scanf("%d",&n);
w=n/10000; q=n/1000%10; b=n/100%10; s=n/10%10; g=n%10;
if(w==g && q==s)
printf("%d 是对称数 \n",n);
else printf("%d 不是对称数 \n",n);
}
24.htm
01.
编一个 程序,从键盘上输入一个字符:
C
若该字符是数字字符,则把它转换为对应的整数并输出;
若该字符是大写字母,则转换成小写并输出;
若该字符是小写字母,则转换为大写并输出;
若该字符是其他字符,则不进行任何操作。
#include
void main()
{ char c;
scanf("%c",&c);
if(c>='0'&&c<='9') printf("%d\n",c-'0');
else if(c>='A'&&c<='Z') printf("%c\n",c+32);
else if(c>='a'&&c<='z') printf("%c\n",c-32);
}
02.
输入三个整数,按从大到小的顺序输出。
#include
void main()
{ int a,b,c,t;
scanf("%d%d%d",&a,&b,&c);
if (a
{ t=a;a=b;b=t; }
if (a
{ t=a;a=c;c=t; }
if (b
{ t=b;b=c;c=t; }
printf( “d%,%d ,%d ",a,b,c);
}
03.
给出一个百分制的成绩,要求输