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

Compare commits

..

No commits in common. "ddd64d9607266a390e04856cb765450e3643aa28" and "012b17b86713d42fa83a883bc9857405a79b68bb" have entirely different histories.

39 changed files with 0 additions and 635 deletions

View File

@ -1,15 +0,0 @@
#include <stdio.h>
int main() {
int a, b;
scanf("%d%d", &a, &b);
if (a < b) {
printf("%d\n", a);
} else {
printf("%d\n", b);
}
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 KiB

View File

@ -1,17 +0,0 @@
#include <stdio.h>
int main() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if (a == b && b == c) {
printf("bian\n");
} else if (a == b || b == c || a == c) {
printf("yao\n");
} else {
printf("triangle\n");
}
return 0;
}

View File

@ -1,21 +0,0 @@
#include <stdio.h>
int main() {
char grade;
scanf("%c", &grade);
if (grade == 'A') {
printf("85~100\n");
} else if (grade == 'B') {
printf("70~84\n");
} else if (grade == 'C') {
printf("60~69\n");
} else if (grade == 'D') {
printf("<60\n");
} else {
printf("Error\n");
}
return 0;
}

View File

@ -1,15 +0,0 @@
#include <stdio.h>
int main() {
char c;
scanf("%c", &c);
if (c >= 'a' && c <= 'z') {
printf("%c\n", c - 32);
} else if (c >= 'A' && c <= 'Z') {
printf("%c\n", c + 32);
}
return 0;
}

View File

@ -1,17 +0,0 @@
#include <stdio.h>
int main() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if (a > b && a > c) {
printf("%d\n", a);
} else if (b > a && b > c) {
printf("%d\n", b);
} else {
printf("%d\n", c);
}
return 0;
}

View File

@ -1,16 +0,0 @@
#include <stdio.h>
int main() {
int n;
int sum = 0;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
sum += i;
}
printf("%d\n", sum);
return 0;
}

View File

@ -1,51 +0,0 @@
#include <stdio.h>
int main() {
int x, a, b, c;
scanf("%d%d%d%d", &x, &a, &b, &c);
switch (x) {
case 0:
printf("%d", a + b);
break;
case 1:
printf("%d", a - b);
break;
case 2:
printf("%d", a * b);
break;
case 3:
printf("%d", a / b);
break;
case 4:
printf("%d", a % b);
break;
case 5:
printf("%d", a ? b : c);
break;
case 6:
printf("%d", a > b);
break;
case 7:
printf("%d", a < b);
break;
case 8:
printf("%d", a != b);
break;
case 9:
printf("%d", a == b);
break;
}
return 0;
}

View File

@ -1,12 +0,0 @@
#include <math.h>
#include <stdio.h>
int main() {
double n;
scanf("%lf", &n);
printf("%d %d %.5lf\n", (int)ceil(n), (int)floor(n), n);
return 0;
}

View File

@ -1,19 +0,0 @@
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int a = n / 100;
int b = n / 10 % 10;
int c = n % 10;
if (n == a * a * a + b * b * b + c * c * c) {
printf("yes\n");
} else {
printf("no\n");
}
return 0;
}

View File

@ -1,17 +0,0 @@
#include <stdio.h>
int main() {
double a, b, c;
scanf("%lf%lf%lf", &a, &b, &c);
if (a + b > c && a + c > b && b + c > a) {
double p = (a + b + c) / 2;
double s = sqrt(p * (p - a) * (p - b) * (p - c));
printf("%.2lf %.2lf\n", s, a + b + c);
} else {
printf("no triangle\n");
}
return 0;
}

View File

@ -1,18 +0,0 @@
#include <math.h>
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int m = sqrt(n);
if (m * m == n) {
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}

View File

@ -1,15 +0,0 @@
#include <stdio.h>
int main() {
int a;
scanf("%d", &a);
if (a % 2 == 1) {
printf("YES\n");
} else {
printf("NO\n");
}
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

View File

@ -1,15 +0,0 @@
#include <stdio.h>
int main() {
int xL, yL, xR, yR, x, y;
scanf("%d%d%d%d%d%d", &xL, &yL, &xR, &yR, &x, &y);
if (x >= xL && x <= xR && y <= yL && y >= yR) {
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}

View File

@ -1,17 +0,0 @@
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n % 2 == 0) {
printf("%d is an even number\n", n);
} else if (n % 3 == 0) {
printf("%d is an odd number,it can be divided by 3\n", n);
} else {
printf("%d is an odd number,it can't be divided by 3\n", n);
}
return 0;
}

View File

@ -1,31 +0,0 @@
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
switch (n) {
case 1:
printf("8\n");
break;
case 2:
printf("4.5\n");
break;
case 3:
printf("12.8\n");
break;
case 4:
printf("3\n");
break;
default:
printf("Exit\n");
break;
}
return 0;
}

View File

@ -1,20 +0,0 @@
#include <stdio.h>
int main() {
int t;
scanf("%d", &t);
double s1 = 25 + 0.1 * t;
double s2 = 20;
if (t >= 100) s2 = 0.3 * t;
if (s1 > s2) {
printf("2\n");
} else {
printf("1\n");
}
return 0;
}

View File

@ -1,17 +0,0 @@
#include <stdio.h>
int main() {
int x;
scanf("%d", &x);
if (x <= 800) {
printf("0.0\n");
} else if (x <= 4000) {
printf("%.1lf\n", (x - 800) * 0.15);
} else {
printf("%.1lf\n", x * 0.1);
}
return 0;
}

View File

@ -1,15 +0,0 @@
#include <stdio.h>
int main() {
double a;
scanf("%lf", &a);
if (a >= 0 && (int)a == a) {
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}

View File

@ -1,31 +0,0 @@
#include <stdio.h>
int main() {
int x;
scanf("%d", &x);
int canFill = 0;
for (int a = 0; a <= x / 4; a++) {
for (int b = 0; b <= x / 5; b++) {
for (int c = 0; c <= x / 7; c++) {
// 计算当前组合的体积
if (4 * a + 5 * b + 7 * c == x) {
canFill = 1;
break;
}
}
if (canFill) break;
}
if (canFill) break;
}
if (canFill) {
printf("ni bu yao guo lai a!\n");
} else {
printf("What a lucky day!\n");
}
return 0;
}

View File

@ -1,24 +0,0 @@
#include <stdio.h>
int main() {
int n;
int a, b, c, d, e, f, g;
scanf("%d", &n);
a = n / 1000000;
b = n / 100000 % 10;
c = n / 10000 % 10;
d = n / 1000 % 10;
e = n / 100 % 10;
f = n / 10 % 10;
g = n % 10;
if (a == g && b == f && c == e) {
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}

View File

@ -1,16 +0,0 @@
#include <stdio.h>
int main() {
int h, m;
scanf("%d:%d", &h, &m);
double angle = 30 * h - 5.5 * m;
if (angle < 0) angle = -angle;
if (angle > 180) angle = 360 - angle;
printf("%.3lf\n", angle);
return 0;
}

View File

@ -1,31 +0,0 @@
#include <math.h>
#include <stdio.h>
int main() {
double a, b, c;
scanf("%lf%lf%lf", &a, &b, &c);
double delta = b * b - 4 * a * c;
if (delta > 0) {
double x1 = (-b - sqrt(delta)) / (a * 2);
double x2 = (-b + sqrt(delta)) / (a * 2);
if (x1 > x2) {
double temp = x1;
x1 = x2;
x2 = temp;
}
printf("%.2lf %.2lf\n", x1, x2);
} else if (delta == 0) {
double x1 = -b / (a * 2);
printf("%.2lf\n", x1);
} else {
printf("No solution\n");
}
return 0;
}

View File

@ -1,15 +0,0 @@
#include <stdio.h>
int main() {
char c;
scanf("%c", &c);
if ('0' <= c && c <= '9') {
printf("%d\n", c);
} else {
printf("input error\n");
}
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 KiB

View File

@ -1,20 +0,0 @@
#include <stdio.h>
int main() {
int a, b;
scanf("%d%d", &a, &b);
// [Theorem]
// In a normal nim game, the player making the first move has a winning strategy
// if and only if the nim-sum of the sizes of the heaps is not zero. Otherwise,
// the second player has a winning strategy.
// Source: https://en.wikipedia.org/wiki/Nim
if ((a ^ b) == 0) {
printf("abcdxyzk\n");
} else {
printf("AekdyCoin\n");
}
return 0;
}

View File

@ -1,29 +0,0 @@
#include <stdio.h>
int main() {
int total, andy, ban;
scanf("%d%d%d", &total, &andy, &ban);
int andyDiff = total - andy;
int banDiff = total - ban;
if (andyDiff < 0) andyDiff = -andyDiff;
if (banDiff < 0) banDiff = -banDiff;
if (andyDiff == banDiff) {
if (andy < ban) {
printf("Andy\n");
} else if (andy == ban) {
printf("Peace\n");
} else {
printf("Ban\n");
}
} else if (andyDiff < banDiff) {
printf("Andy\n");
} else {
printf("Ban\n");
}
return 0;
}

View File

@ -1,21 +0,0 @@
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n >= 1 && n <= 10) {
printf("%d\n", n);
} else if (n == 11) {
printf("J\n");
} else if (n == 12) {
printf("Q\n");
} else if (n == 13) {
printf("K\n");
} else {
printf("NO\n");
}
return 0;
}

View File

@ -1,15 +0,0 @@
#include <stdio.h>
int main() {
int year;
scanf("%d", &year);
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
printf("YES\n");
} else {
printf("NO\n");
}
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 KiB

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

View File

@ -1,18 +0,0 @@
#include <math.h>
#include <stdio.h>
int main() {
double x;
scanf("%lf", &x);
if (x < 1) {
printf("%.3lf\n", x);
} else if (1 <= x && x < 10) {
printf("%.3lf\n", sqrt(x * 2 - 1));
} else { // x >= 10
printf("%.3lf\n", log(x * 3 - 11));
}
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 KiB

View File

@ -1,18 +0,0 @@
#include <stdio.h>
int main() {
double x, y;
scanf("%lf%lf", &x, &y);
if ((x - 2) * (x - 2) + (y - 2) * (y - 2) <= 1
|| (x + 2) * (x + 2) + (y - 2) * (y - 2) <= 1
|| (x + 2) * (x + 2) + (y + 2) * (y + 2) <= 1
|| (x - 2) * (x - 2) + (y + 2) * (y + 2) <= 1) {
printf("10\n");
} else {
printf("0\n");
}
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 KiB

View File

@ -1,19 +0,0 @@
#include <stdio.h>
int main() {
int x;
scanf("%d", &x);
if (x == 5) {
printf("6\n");
} else if (x == 6) {
printf("10\n");
} else if (x == 7) {
printf("8\n");
} else {
printf("4\n");
}
return 0;
}

View File

@ -1,15 +0,0 @@
#include <stdio.h>
int main() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if (a + b > c && a + c > b && b + c > a) {
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}