1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-08 11:08:41 +00:00

【额外练习】选择结构

This commit is contained in:
Baoshuo Ren 2024-11-02 22:07:00 +08:00
parent 01f72aa8a0
commit febf51beea
Failed to extract signature
3 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,17 @@
#include <stdio.h>
int main() {
double a, b, m, n;
scanf("%lf%lf%lf%lf", &a, &b, &m, &n);
if (m == a && n == b) {
printf("3\n");
} else if (m == a || n == b) {
printf("4\n");
} else {
printf("5\n");
}
return 0;
}

View File

@ -0,0 +1,24 @@
#include <stdio.h>
int main() {
int year;
double time;
scanf("%d%lf", &year, &time);
if (year >= 5) {
if (time <= 40) {
printf("%.2lf\n", time * 50);
} else {
printf("%.2lf\n", 40 * 50 + (time - 40) * 50 * 1.5);
}
} else {
if (time <= 40) {
printf("%.2lf\n", time * 30);
} else {
printf("%.2lf\n", 40 * 30 + (time - 40) * 30 * 1.5);
}
}
return 0;
}

View File

@ -0,0 +1,22 @@
#include <math.h>
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int x = sqrt(n);
if (x * x == n) {
if (x % 2 == 0) {
printf("Even special number\n");
} else {
printf("Odd special number\n");
}
} else {
printf("No\n");
}
return 0;
}