# 計算機程式設計問題?

/*輸入總秒數後將其轉換成幾時幾分幾秒,程式執行顯示如下:

hh:mm:ss = 01:52:28

*/

/* 參考程式 */

#include <stdic.h>

#include "stdlib.h"

int main(int argc, char *argv[])

{

int tsec,hour,minute,second;

printf("請輸入準備轉換的秒數:");

scanf("%f",tsec);

second=tsec%60;

minute=(tsec/60)%60;

hour=tsec/60/60;

printf("hh:mm:ss = %02d:%02f:%02d\n",&hour,minute,second);

system("PAUSE");

return 0;

}

-------------------------------------------------------------------

2. 請寫一溫度轉換程式將攝氏(c)溫度轉換為華氏溫度(f)?

### 1 個解答

• 9 年前
最佳解答

#include <stdio .h> //.............1

#include "stdlib.h"

#include <vcl.h>

#pragma hdrstop//---------------------------------------------------------------------------#pragma argsused

int main(int argc, char *argv[])

{

int tsec,hour,minute,second;

printf("請輸入準備轉換的秒數:");

scanf("%d ",& tsec); //............2 second=tsec%60;

minute=(tsec/60)%60;

hour=tsec/60/60; printf("hh:mm:ss = %02d:%02d:%02d\n",hour,minute,second); //..........3.

system("PAUSE");

return 0;

}

//========= 第二題 ==================

int main(int argc, char *argv[])

{

int tsec;

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

scanf("%d",&tsec); printf("華氏= %d\n",tsec*9/5+32);

system("PAUSE");

return 0;

}