(1-2)
Description
计算两整数x和y(0<x,y<1000)的和、差、积、商、余数、x的平方和y的三次方。
Input
输入只有一行,格式见sample。
Output
输出为多行,按顺序每行输出x,y的和、差、积、商、余数、x的平方和y的三次方,格式见sample
Sample Input
x = 11, y = 3
Sample Output
x + y : 14
x - y : 8
x * y : 33
x / y quotient: 3, remainder: 2
x ^ 2 : 121
y ^ 3 : 27
HINT
注意输入输出格式。了解C语言整数除法运算符的特点,并且没有求幂的运算符
#include <stdio.h>
int main()
{
int x,y;
0<x<1000,0<y<1000;
scanf("x = %d, y = %d",&x,&y);
printf("x + y : %d\n",x+y);
printf("x - y : %d\n",x-y); 地漏反味怎么解决
printf("x * y : %d\n",x*y);
printf("x / y quotient: %d, remainder: %d\n",x/y,x%y);
printf("x ^ 2 : %d\n",x*x);
printf("y ^ 3 : %d\n",y*y*y);
return 0;
}
(1-3)
Description
从键盘输入圆的半径,求圆的面积和周长,圆周率取3.14。
Input
输入一个浮点型数据,有效数字不会超过十进制的6位。
Output
输出为两行。
第一行为圆的面积,第二行为圆的周长,格式见sample。
Sample Input
3
Sample Output
Area: 28.260000
Perimeter: 18.840000
可爱的中国全文
HINT
了解浮点类型的输入、输出和算术运算符
#include <stdio.h>
#define P 3.14
int main()
{
float r,s,c;
scanf("%f",&r);
s=P*r*r;
c=2*r*P;
printf("Area: %f\n",s);
printf("Perimeter: %f\n",c);
return 0;
}
(1-4)
Description
求3个数的平均值。
Input
输入只有一行,为3个较小的整数。
Output
儿童好书推荐输出为这3个整数的平均值,保留3位小数。
Sample Input
1 2 3
Sample Output
水龙吟辛弃疾
2.000
HINT
注意除法运算对整型数据和浮点型数据是不一样的
#include <stdio.h>
一望无际是什么意思int main()
南溪公园
{
int a,b,c;
float Aver;
scanf("%d %d %d",&a,&b,&c);
Aver=(a+b+c)/3.0;
printf("%.3f\n",Aver);
return 0;
}
(1-5)
Description
给出人民币对美元、欧元、日元的当日汇率,求给定金额的人民币能兑换成外币的金额,求给定金额的外币能兑换成人民币的金额。
要计算的外币有三种:美元、欧元、日元。
Input
输入有三行。
第一行依次为美元、欧元、日元外币汇率,用空格分开。汇率用100外币为单位,精确到小数点后4位,如668.5200表示“100美元=668.5200人民币”。汇率浮动范围为(0,10000)。
第二行为外币金额x,第三行为人民币金额y。x,y均为整数,且0<x,y<10000。
Output
输出为两行。
第一行为金额为x的美元、欧元、日元兑换成人民币的金额,用空格分开。
第二行为金额为y的人民币兑换成美元、欧元、日元的金额,用空格分开。
所有金额精确到小数点后两位。
Sample Input
668.5200 908.0685 7.9852
1500
1500
Sample Output
10027.80 13621.03 119.78
224.38 165.19 18784.75
HINT
了解浮点数据类型的精确度和输出控制。
#include <stdio.h>
int main()
{
double x,y;
double a,b,c,i,j,k,l,m,n;
scanf("%lf%lf%lf",&a,&b,&c);
scanf("%lf",&x);
scanf("%lf",&y);
i=x/100*a;
j=x/100*b;
k=x/100*c;
l=y/a*100;
m=y/b*100;
n=y/c*100;
printf("%.2lf %.2lf %.2lf\n",i,j,k);
printf("%.2lf %.2lf %.2lf\n",l,m,n);
return 0;
}
(1-6)
Problem F: 求字符的值
Time Limit: 1 Sec Memory Limit: 2 MB
Submit: 562 Solved: 373
[Submit][Status][Web Board]
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
HINT
了解字符值的存储和整型的关系。
#include <stdio.h>
int main()
{
char a,b,c;
scanf("%c%c%c",&a,&b,&c);
printf("%.3d %.3o %.3x\n",a,a,a);
printf("%.3d %.3o %.3x\n",b,b,b);
printf("%.3d %.3o %.3x\n",c,c,c);
return 0;
}
(1-7)
Problem G: 奇数还是偶数?
Time Limit: 1 Sec Memory Limit: 2 MB
Submit: 575 Solved: 455
[Submit][Status][Web Board]
Description
输入一个整数,判读它是奇数还是偶数。
Input
输入只有一行,为一个100以内的正整数。
Output
输出为一行。
若输入为偶数则输出“even”,奇数输出“odd”。
Sample Input
30
Sample Output
even
HINT
用整数运算可以解决,练习“?:”表达式。
#include <stdio.h>
int main()
{
int a;
(0<a)&&(a<100);
scanf("%d",&a);
if (a%2==0)
printf("even\n");
el
printf("odd\n");
return 0;
}
(1-8)
Problem H: 绝对值
Time Limit: 1 Sec Memory Limit: 2 MB
Submit: 840 Solved: 376
[Submit][Status][Web Board]
Description
求整型数据和浮点型数据的绝对值。
Input
输入两个数,第一个是整数,第二个是浮点数。