書本3

1:ASCII #include<stdio.h> #include<stdlib.h> int main() { char ASCII; printf("請輸入一個ASCII值:"); scanf("%d", &ASCII); printf("對應的ASCII值爲%c", ASCII); system("pause"); return 0; } 2:計數法 #include<stdio.h> #include<stdlib.h> int main() { float a; printf("Enter a floating-point value:"); scanf("%f", &a); printf("fixed-point notation:%.6f\n", a); printf("exponential notation:%e\n",a); printf("p notation:%a", a); system("pause"); return 0; } 3:警報 #include<stdio.h> #include<stdlib.h> int main() { putchar('\a'); printf("Startled by the sudden sound, Sally shouted,\n"); printf("「By the Great Punpkin,what was that!」"); system("pause"); return 0; } 4:年換秒 #include<stdio.h> #include<stdlib.h> #include<math.h> int main() { float a, b; printf("請輸入你的年齡:"); scanf("%f", &a); b = 3.156 * pow(10, 7) * a; printf("年齡對應的秒數爲%f", b); system("pause"); return 0; } 5:身高轉換 #include<stdio.h> #include<stdlib.h> int main() { float inch, cm; printf("請輸入你的英尺身高:"); scanf("%f", &inch); cm = inch / 2.54; printf("你的身高是%f釐米", cm); system("pause"); return 0; } 6:水分子數 #include<stdio.h> #include<stdlib.h> #include<math.h> int main() { float kt, fz; printf("請輸入水的夸脫數:"); scanf("%f", &kt); fz = kt * 950 /3 / pow(10, -23); printf("對應的水分子數量爲%f", fz); system("pause"); return 0; } 8:體積變化 #include<stdio.h> #include<stdlib.h> int main() { float p, b, a, t, c; printf("請輸入杯數:"); scanf("%f", &b); p = 2 * b; a = b / 8; t = b / 16; c = b / 48; printf("對應的爲%f品脫", p); printf("對應的爲%f盎司", a); printf("對應的爲%f大湯匙", t); printf("對應的爲%f茶勺", c); system("pause"); return 0; }io

相關文章
相關標籤/搜索