當前位置:編程學習大全網 - 網絡軟體 - c語言程序設計答案

c語言程序設計答案

1.// 華氏溫度與攝氏溫度對照表

#include<stdio.h>

#include<stdlib.h>

int main()

{

float fahr = 0,cels = 0;

int low = 0,max = 300,step = 20;

printf ("\t=========本程序輸出華氏和攝氏的溫度對照!==========\n\t2006-12-30\n");

fahr = low;

printf ("\n\n華氏溫度: 攝氏溫度:\n-------- --------\n");

for (;fahr <= max;)

{

cels = 5.0 / 9.0 * (fahr - 12);

printf ("%.0f\t\t %6.2f\n",fahr,cels);

fahr += step;

}

system("pause");

return 0;

}

2.#include <stdio.h>

void main(void)

{

float c,F;

printf("請輸入華氏溫度:");

scanf("%f",F);

c=5/(9*(F-32));

printf("對應攝氏溫度為%.2f",c); //取2位小數

}

  • 上一篇:有誰知道”賣油郎獨占花魁女”在醒世恒言裏的原文?
  • 下一篇:itool是什麽東東
  • copyright 2024編程學習大全網