目前分類:C (23)

瀏覽方式: 標題列表 簡短摘要
#include <stdio.h>
#include <stdlib.h>

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

//華氏溫度
int Fah;
        //攝氏溫度
float Cel;


printf("input Fah:");

scanf("%i", &Fah);

//C++內的5.0是指5.0d,C內的5.0指5.0f
Cel = (Fah - 32)*(5.0f / 9);

printf("Cel is %.2f ", Cel);

return 0;
}

kenohya 發表在 痞客邦 留言(0) 人氣()

#include <stdio.h>
#include <stdlib.h>

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

int price;
float discounts, total;

printf("老闆請問多少錢?\n");


 //取記憶體price的數值
scanf("%i", &price);

printf("老闆請問打幾折?\n");
scanf("%f", &discounts);

 //算出total價格
total = price*discounts/10;

//取小數點後2位
printf("打 %.2f 折後為%f", discounts, total);

return 0;
}

kenohya 發表在 痞客邦 留言(0) 人氣()

#include <stdio.h>
#include <stdlib.h>

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

int enter;

//請求輸入-->轉譯 -->放入記憶體位置
printf("input:\n");

//記憶體取 &enter值,丟到 %i
//&是取得記憶體空間的意思
scanf("%i", &enter);


//印出輸入的值
printf("your input is :%i\n",enter);

       //0表示關閉程式
return 0;
}

kenohya 發表在 痞客邦 留言(0) 人氣()

«12