10、 水仙花数
Description
如果一个三位十进制数等于其各位数字的立方和,则称这个数为水仙花数。如:13+53+33=153。 Input
一个整数x,100<=x<=999。 Output
x是水仙花数,则输出“YES”,否则为“NO”。 Sample Input 153
Sample Output YES Answer
#include
int a,b,c,d,e; scanf(\ b=a/100;
c=(a-b*100)/10; d=(a-b*100-c*10);
e=b*b*b+c*c*c+d*d*d; if(a==e)
printf(\ else
printf(\ return 0; }
11、 三个数比较大小
Description
从键盘上输入0~100之间的三个数,按从小到大的顺序输出。 Input
输入只有一行,为三个整数。 Output
按从小到大输出这三个数。 Sample Input 15 10 20
Sample Output 10 15 20 Answer
#include
}
if (a>=c) printf(\ else if (b>=c) printf(\ else printf(\}
return 0;
12、 输出整数的最低两位
Description
把一个整数的最低两位打印出来,不输出整数的符号。 Input
输入为一个整数n,不会超出int类型的数据范围。 Output
输出n的最低两位数字。但是,输入的数字本身不足两位时,不应当补0。如,输入为“1”,则输出为“1”。 Sample Input -102
Sample Output 02
Answer
#include
13、判断奇偶数(填空)
Description
编写一个程序,判断读取的正整数的奇偶性,部分程序已经给出,请填上空白语句,并提交填充后的完整程序。 程序(含答案): #include
int num;
scanf(\ if (num%2==0) printf(\是一个偶数 else
printf(\是一个奇数 return 0; }
14、求分段函数的值(填空)
Description
设有分段函数如下:
给出N>0个x的值,求对应的y值并输出。
部分程序已经给出,请填充其中的空白语句,并提交填充后的完整程序。 程序(含答案): #include
double x,y; int i,N;
scanf(\ for (i=0;i scanf(\ if (x<0) y=-x; else if (x<1) y=sin(2*x); else if (x<5) y=sqrt(x*x*x+x); else y=2*x+10; if (i==0) printf(\ else printf(\ } return 0; } 15、输出是m的倍数或n的倍数、但不是m和n的公倍数的数 Description 输出1~k之间是m的倍数或n的倍数、但不是m和n的公倍数的数,其中1<=m,n 输入三个整数,依次为k、m、 n。 Output 从小到大输出符合题意的所有整数,两数之间用一个空格分开。 Sample Input 15 2 3 Sample Output 2 3 4 8 9 10 14 15 Answer #include 16、A+B ProblemT Description 计算a+b,0<=a,b<1000。 Input 输入有多对整数a和b组成,每对a和b占一行,a,b用空格分开。 Output 每行输出一个a+b的值,顺序与输入对应。 Sample Input 1 2 10 20 Sample Output 3 30 Answer #include 17、A+B Problem (II) : Input/Output Pratice Description 计算a+b,0<=a,b<1000。 Input 输入的第一行是一个整数N,后面有N对整数a和b,每对a和b占一行,a,b用空格分开。 Output 每行输出一个a+b的和,顺序与输入对应。 Sample Input 2 1 2 10 20 Sample Output 3 30 Answer #include 18、成绩的等级 Description 把百分制的考试成绩转换成五级制的成绩: 90~100:Excellent 80~89:Good 70~79:Average 60~69:Pass 0~59:Failing 不在0~100之间的输入是非法数据,输出“Error”。 Input 输入多行,每行一个整数。 Output 输入所对应的成绩等级。 Sample Input -1 81 92 35 68 72 100 Sample Output Error Good Excellent Failing Pass Average Excellent Answer #include int score; while(scanf(\ { if (score<0||score>100) printf(\ else {