練習2-1spa
1 #include <stdio.h> 2 3 int main() { 4 int x; 5 int y; 6 int percent; 7 8 puts("請輸入兩個整數"); 9 printf("整數x:"); 10 scanf("%d", &x); 11 printf("整數y:"); 12 scanf("%d", &y); 13 percent = (x *100 )/ y; 14 printf("x的值是y的%d%%", percent); 15 16 return 0; 17 }
練習2-2code
1 #include <stdio.h> 2 3 int main() { 4 int x; 5 int y; 6 7 puts("請輸入兩個整數"); 8 printf("整數x:"); 9 scanf("%d", &x); 10 printf("整數y:"); 11 scanf("%d", &y); 12 printf("他們的和是%d,積是%d", x+y,x*y); 13 14 return 0; 15 }
練習2-3blog
1 #include <stdio.h> 2 3 int main() { 4 double x; 5 printf("請輸入一個實數:"); 6 scanf("%lf", &x); 7 printf("你輸入的值是:%f", x); 8 return 0; 9 }
練習2-4io
略class
練習2-5di
1 #include <stdio.h> 2 3 int main() { 4 int x; 5 int y; 6 puts("請輸入兩個整數。"); 7 printf("整數a:"); 8 scanf("%d", &x); 9 printf("整數b:"); 10 scanf("%d", &y); 11 printf("a是b的%f%%", (double)x / y * 100); 12 return 0; 13 }
練習2-6co
1 #include <stdio.h> 2 3 int main() { 4 int x; 5 printf("請輸入你的身高:"); 6 scanf("%d", &x); 7 printf("您的標準體重是:%.1f公斤", (x - 100) * 0.9); 8 9 return 0; 10 }