mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-11-23 15:48:42 +00:00
【实践课外】1.顺序结构
This commit is contained in:
parent
33b7aa9603
commit
887f488943
11
【实践课外】1.顺序结构/7-1 是不是太胖了.c
Normal file
11
【实践课外】1.顺序结构/7-1 是不是太胖了.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int h;
|
||||
|
||||
scanf("%d", &h);
|
||||
|
||||
printf("%.1lf\n", (double)(h - 100) * 0.9 * 2);
|
||||
|
||||
return 0;
|
||||
}
|
BIN
【实践课外】1.顺序结构/7-1 是不是太胖了.jpg
Normal file
BIN
【实践课外】1.顺序结构/7-1 是不是太胖了.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 281 KiB |
14
【实践课外】1.顺序结构/7-2 计算存款利息.c
Normal file
14
【实践课外】1.顺序结构/7-2 计算存款利息.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
double money, year, rate;
|
||||
|
||||
scanf("%lf%lf%lf", &money, &year, &rate);
|
||||
|
||||
double k = pow(rate + 1, year);
|
||||
|
||||
printf("interest = %.2lf\n", money * k - money);
|
||||
|
||||
return 0;
|
||||
}
|
BIN
【实践课外】1.顺序结构/7-2 计算存款利息.jpg
Normal file
BIN
【实践课外】1.顺序结构/7-2 计算存款利息.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 277 KiB |
15
【实践课外】1.顺序结构/7-3 整数算术运算.c
Normal file
15
【实践课外】1.顺序结构/7-3 整数算术运算.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int a, b;
|
||||
|
||||
scanf("%d%d", &a, &b);
|
||||
|
||||
printf("%d + %d = %d\n", a, b, a + b);
|
||||
printf("%d - %d = %d\n", a, b, a - b);
|
||||
printf("%d * %d = %d\n", a, b, a * b);
|
||||
printf("%d / %d = %d\n", a, b, a / b);
|
||||
printf("%d %% %d = %d\n", a, b, a % b);
|
||||
|
||||
return 0;
|
||||
}
|
BIN
【实践课外】1.顺序结构/7-3 整数算术运算.jpg
Normal file
BIN
【实践课外】1.顺序结构/7-3 整数算术运算.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 268 KiB |
16
【实践课外】1.顺序结构/7-4 21-大鸟转转转实验室.c
Normal file
16
【实践课外】1.顺序结构/7-4 21-大鸟转转转实验室.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
|
||||
scanf("%d", &n);
|
||||
|
||||
int a = n % 10;
|
||||
int b = n / 10 % 10;
|
||||
int c = n / 100 % 10;
|
||||
int d = n / 1000;
|
||||
|
||||
printf("%d\n", a * 1000 + b * 100 + c * 10 + d);
|
||||
|
||||
return 0;
|
||||
}
|
BIN
【实践课外】1.顺序结构/7-4 21-大鸟转转转实验室.jpg
Normal file
BIN
【实践课外】1.顺序结构/7-4 21-大鸟转转转实验室.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 314 KiB |
14
【实践课外】1.顺序结构/7-5 石头剪刀布.c
Normal file
14
【实践课外】1.顺序结构/7-5 石头剪刀布.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int n;
|
||||
double p1, p2, p3, q1, q2, q3;
|
||||
|
||||
int main() {
|
||||
scanf("%d%lf%lf%lf%lf%lf%lf", &n, &p1, &p2, &p3, &q1, &q2, &q3);
|
||||
|
||||
double win = p1 * q2 + p2 * q3 + p3 * q1;
|
||||
|
||||
printf("%.4lf\n", win * n);
|
||||
|
||||
return 0;
|
||||
}
|
BIN
【实践课外】1.顺序结构/7-5 石头剪刀布.png
Normal file
BIN
【实践课外】1.顺序结构/7-5 石头剪刀布.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 332 KiB |
Loading…
Reference in New Issue
Block a user