小屋創作

日誌2019-11-17 04:33

C語言 期中考

作者:DIS黒き銃神(祭絲tama子)

清淨氣溫:
#include <stdio.h>
#include <stdlib.h>

int main(){
    char *std_num="123456", *name="XXX";
    printf("學號:%s \n姓名:%s \n", std_num, name);
    
    float surface_temp;   //平地氣溫
    float qingjing_temp;  //清淨氣溫
    printf("請輸入平地氣溫:");
    scanf("%f", &surface_temp);
    
    qingjing_temp = surface_temp-(17*0.6);
    
    printf("清淨氣溫為:%.1f\n", qingjing_temp);
    
    system("PAUSE");
    return 0;
}

所得稅計算:
#include <stdio.h>
#include <stdlib.h>

int main(){
    char *std_num="123456", *name="XXX";
    printf("學號:%s \n姓名:%s \n", std_num, name);
    
    int income;  //收入
    float tax;   //稅額
    
    //稅率
    int s5 = 54*10000*0.05;   //5%
    int s12 = 67*10000*0.12;  //12%
    int s20 = 121*10000*0.2;  //20%
    int s30 = 211*10000*0.3;  //30%
    //40%
    
    printf("請輸入收入(萬元):");
    scanf("%d", &income);
    
    if (income < 54)
        tax = income*10000*0.05;
    else if (income <= 121)
        tax = (income-54)*10000*0.12+s5;
    else if (income <= 242)
        tax = (income-121)*10000*0.2+s12+s5;
    else if (income <= 453)
        tax = (income-242)*10000*0.3+s20+s12+s5;
    else if (income < 453)
        tax = income*10000*0.4+s30+s20+s12+s5;
    else
        tax = income*10000*0.05;
    
    printf("應繳稅額為:%.0f\n", tax);
    
    system("PAUSE");
    return 0;
}

4

2

LINE 分享

相關創作

手動編譯安裝 LLVM 工具

C語言變數生命週期觀察與Lambda運算式入門

C語言變數生命週期觀察與Lambda運算式,補充unique_ptr

留言

開啟 APP

face基於日前微軟官方表示 Internet Explorer 不再支援新的網路標準,可能無法使用新的應用程式來呈現網站內容,在瀏覽器支援度及網站安全性的雙重考量下,為了讓巴友們有更好的使用體驗,巴哈姆特即將於 2019年9月2日 停止支援 Internet Explorer 瀏覽器的頁面呈現和功能。
屆時建議您使用下述瀏覽器來瀏覽巴哈姆特:
。Google Chrome(推薦)
。Mozilla Firefox
。Microsoft Edge(Windows10以上的作業系統版本才可使用)

face我們了解您不想看到廣告的心情⋯ 若您願意支持巴哈姆特永續經營,請將 gamer.com.tw 加入廣告阻擋工具的白名單中,謝謝 !【教學】