输出为两行。
第一行为金额为x的美元、欧元、日元兑换成人民币的金额,用空格分开。 第二行为金额为y的人民币兑换成美元、欧元、日元的金额,用空格分开。 所有金额精确到小数点后两位。 Sample Input
668.5200 908.0685 7.9852 1500 1500
Sample Output
10027.80 13621.03 119.78
#include int main() {
double i,j,k,a,b,c,d,e,f; double x,y;
scanf (\ scanf (\
a=x/100*i;b=y/100*j;c=x/100*k; d=y*100/i;e=y*100/j;f=y*100/k;
printf (\ printf (\}
Problem E: 求字符的值
Description
从键盘输入3个字符(不含双字节字符),分别输出每个字符的十进制值(ASCII码)、八进制值和十六进制值。 Input
输入为3个字符。 Output
输出为3行。
每一行为每个字符(对应输入顺序)的十进制、八进制和十六进制值,用空格分隔开。每个输出的值占3个字符,不足3个字符前面补0。 Sample Input
0 A
Sample Output
048 060 030 032 040 020
065 101 041
#include int main() {
char x,y,z;
scanf (\
printf (\ printf (\ printf (\ }
Problem A: 简单的打折计算 Description
商店规定:消费满n元,可以打八八折。设某件商品标价m元,输入购买的件数x,计算出需要支付的金额(单位:元),精确到分。 Input
输入只有一行,三个整数m、n和x,且0输出金额,精确到分。 Sample Input
95 300 4
Sample Output
334.40
HINT
了解浮点型的输出控制,注意整型和浮点型混合运算过程中的数据类型转换。 #include int main() {int m,n,x; float s;
scanf (\if (m*x>=n)
s=m*x*0.88; else
s=m*x;
printf (\ }
Problem C: 水仙花数 Description
如果一个三位十进制数等于其各位数字的立方和,则称这个数为水仙花数。如:13+53+33=153。 Input
一个整数x,100<=x<=999。 Output
x是水仙花数,则输出“YES”,否则为“NO”。
#include int main() {
int x,a,b,c;
scanf (\ a=x; b=x/10;
c=x/100;
if(a*a*a+b*b*b+c*c*c==x) printf (\ else
printf (\}
Problem A: 多少张钞票 Description
客户去商店买东西时,不超过100美金的账单喜欢用现金支付。商店喜欢用最少的钞票给付客户的找零。请你编写一个程序帮助商店计算出:当客户买了x元商品给了一张100美元的钞票后,商店应该付给客户多少张20美元、10美元、5美元和1美元的钞票,使得钞票总数最少。假设不存在其他面值的钞票,也不会有几角几分的价格,商店的各种钞票总是够用的。 Input
输入一个整数x,0按顺序输出20美金、10美金、5美金和1美金面值的钞票张数。输出格式见sample。 Sample Input
7
Sample Output
$20 bills: 4 $10 bills: 1 $5 bills: 0 $1 bills: 3
#include int main()
{int x,s,a,b,c,d; scanf (\s=100-x; a=s/20;
b=(s-20*a)/10;
c=(s-20*a-10*b)/5; d=s-20*a-10*b-c*5;
printf (\printf (\printf (\printf (\}
Problem B: 自动拨出电话的程序 Sample Input
(0532)621-15486
Sample Output
008653262115486
HINT
这是个可以用scanf()解决的问题,请注意电话号码都是数字这个规律。 #include int main() {
int a,b,c;
scanf(\ printf(\}
///Problem C: 求1+2+...+n=?
Description
给定一个n,求出s = 1+2+3+...+n的值。 Input
输入只有一行,包含一个正整数n(n<=232)。 Output
输出一行,为1+2+...+n的值。 Sample Input
10
Sample Output
55
HINT
n的数据范围大,需注意数据类型的选择和计算次序,以避免数据溢出。 #include int main() {
unsigned long long int n,s,i; scanf(\ if(n%2==0)
s=n/2*(n+1); else
s=(n+1)/2*n; printf (\}
/Problem D: 2的多少次幂 Description
从键盘输入一个数x,x是2的整数次幂(x=2y),请编程求出y的值。 Input
一个非负有理数x,x在[0,2256]范围内。 Output
一个整数y。
#include #include int main() {double x,n;
scanf (\
n=(log10(x))/(log10(2)); printf (\}
Problem A: 输出是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
#include int main() {
int k,m,n,i=0,j;
scanf (\ for (j=1;j<=k;j++) {
if ((j%m==0&&j%n!=0)||(j%m!=0&&j%n==0)) {i++; if(i==1)
printf (\ else
printf (\ } }
/Problem B: n个数的最大值和最小值
Description
找出n个数中最大的数和最小的数,并将它们的值输出出来。 Input
输入为n+1个整数,都在int类型范围内。这些数可能用若干空格或者换行符分隔开。 输入的第1个数为n,表示后续有n个数输入。从输入的第2个数开始,求出直到第n+1个数中最大的数和最小的数。 Sample Input
3 0 1 -1
Sample Output
The maximum number is 1. The minimum number is -1.
#include int main() {
int i,n,m,max,min;
scanf (\ min=max;