【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《温度转换,c语言程序源代码》,欢迎阅读!
#include
int main(int argc, const char * argv[]) {
//温度转换01 int fahr,celaius;
int lower,upper,step;
lower = 0;//温度表下限 upper = 300;//温度表上限 step = 20;//步长
fahr = lower;
while (fahr <= upper) {
celaius = 5 * (fahr - 32)/9;
printf("%d\t%d\n",fahr,celaius); fahr = fahr + step; }
printf("Hello, World!\n"); return 0; }
#include
int main(int argc, const char * argv[]) {
//温度转换02 int fahr;
for (fahr = 0; fahr <= 300; fahr = fahr + 20) { printf("%3d %6.1f\n",fahr,(5.0/9.0)*(fahr-32)); }
printf("Hello, World!\n"); return 0; }
#include
#define LOWER 0//温度表下限 #define UPPER 300//温度表上限 #define STEP 20//步长
int main(int argc, const char * argv[]) {
//温度转换03 int fahr;
for (fahr = LOWER; fahr <= 300; fahr = fahr + STEP) { printf("%3d %6.1f\n",fahr,(5.0/9.0) * (fahr - 32)); }
printf("Hello, World!\n"); return 0; }
本文来源:https://www.wddqxz.cn/a1cb23eab84cf7ec4afe04a1b0717fd5370cb276.html