1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-23 09:38:42 +00:00

【实践课外】1.顺序结构

This commit is contained in:
Baoshuo Ren 2024-10-16 19:31:55 +08:00
parent 33b7aa9603
commit 887f488943
Failed to extract signature
10 changed files with 70 additions and 0 deletions

View 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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 KiB

View 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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 KiB

View 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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 KiB

View 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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 KiB

View 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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB