红皮书_C语言程序设计实用教程参考答案(5)
发布时间:2021-06-07
发布时间:2021-06-07
printf("最高气温与最低气温的差:%d\n",highSubLow); system("PAUSE"); return 0;
} 11.
#include <stdio.h>
int main() { double elephantWeight; //存储大象重量
double antOne,antTwo; //存储两只蚂蚁的重量 double weightSum; //存放重量和 printf("请输入大象和两只蚂蚁的重量:");
scanf("%lf%lf%lf",&elephantWeight,&antOne,&antTwo); printf("两只蚂蚁的重量分别是:\n");
printf("%0.20f和%0.20f\n",antOne,antTwo);
weightSum = antOne+antTwo; printf("两只蚂蚁的重量和:");
printf("%0.20f\n",weightSum); printf("%e\n",weightSum); printf("大象的重量是:\n"); printf("%0.20f\n",elephantWeight);
weightSum =elephantWeight+antOne+antTwo; printf("大象与两只蚂蚁的重量和:");
printf("%0.20f\n",weightSum); printf("%e\n",weightSum); return 0;
}
12.
#include <stdio.h>
int main() { char letter1,letter2,letter3,letter4,letter5,end; printf("请连续输入5个大写字母(然后按Enter):");
letter1 = getchar(); letter2 = getchar();
letter3 = getchar(); letter4 = getchar();
letter5 = getchar();
end = getchar(); //得到用户输入5个字母之后按的回车字符
putchar(letter1+32); putchar(letter2+32);