1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-27 14:36:19 +00:00

Compare commits

..

No commits in common. "889f44af505fb925fab21cae8ef428abdaa4fbc9" and "ddd64d9607266a390e04856cb765450e3643aa28" have entirely different histories.

13 changed files with 0 additions and 222 deletions

View File

@ -1,20 +0,0 @@
#include <stdio.h>
int main() {
int n;
double ans = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
if (i % 2 == 0) {
ans += 1.0 / (1 + 3 * i);
} else {
ans -= 1.0 / (1 + 3 * i);
}
}
printf("sum = %.3lf\n", ans);
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 KiB

View File

@ -1,22 +0,0 @@
#include <math.h>
#include <stdio.h>
int main() {
long long n, ans = 0;
scanf("%lld", &n);
for (long long i = 1; i <= (long long)sqrt(n); i++) {
if (n % i == 0) {
ans += i;
if (i != n / i) {
ans += n / i;
}
}
}
printf("%lld\n", ans);
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 KiB

View File

@ -1,22 +0,0 @@
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
while (n >= 10) {
int s = 0;
while (n) {
s += n % 10;
n /= 10;
}
n = s;
}
printf("%d\n", n);
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 KiB

View File

@ -1,34 +0,0 @@
#include <math.h>
#include <stdio.h>
int main() {
int n;
while (scanf("%d", &n) != EOF, n != 0) {
double ans = n;
for (int i = 2; i <= n; i++) {
ans += (double)(n * 2 - 2 * (i - 1)) / (double)i;
}
/*
for (int i = 1; i <= n; i++) {
// 对角线左侧
for (int j = i; j >= 2; j--) {
ans += 1.0 / j;
}
ans += 1;
// 对角线右侧
for (int j = 2; j <= n - i + 1; j++) {
ans += 1.0 / j;
}
}
*/
printf("%.2lf\n", ans);
}
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 KiB

View File

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

View File

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

View File

@ -1,27 +0,0 @@
#include <stdio.h>
int main() {
double a, b, c;
scanf("%lf%lf%lf", &a, &b, &c);
if (a == 0) {
if (b == 0 && c != 0) {
printf("0\n");
} else {
printf("1\n");
}
} else {
double delta = b * b - 4 * a * c;
if (delta > 0) {
printf("2\n");
} else if (delta == 0) {
printf("1\n");
} else {
printf("0\n");
}
}
return 0;
}

View File

@ -1,26 +0,0 @@
#include <math.h>
#include <stdio.h>
int main() {
double a, b, c, r;
scanf("%lf%lf%lf%lf", &a, &b, &c, &r);
double s = (a + b + c) / 2.0;
if (s <= a || s <= b || s <= c) {
printf("No\n");
return 0;
}
double area = sqrt(s * (s - a) * (s - b) * (s - c));
double inRadius = area / s;
if (r <= inRadius) {
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}

View File

@ -1,23 +0,0 @@
#include <stdio.h>
int main() {
int t;
scanf("%d", &t);
if (t >= 90 && t <= 100) {
printf("A\n");
} else if (t >= 80 && t <= 89) {
printf("B\n");
} else if (t >= 70 && t <= 79) {
printf("C\n");
} else if (t >= 60 && t <= 69) {
printf("D\n");
} else if (t >= 0 && t <= 59) {
printf("E\n");
} else {
printf("Score is error!\n");
}
return 0;
}