0311
This commit is contained in:
parent
747dcefe75
commit
f626c98e12
43
.vscode/c.code-snippets
vendored
Normal file
43
.vscode/c.code-snippets
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"Init file": {
|
||||
"prefix": "init",
|
||||
"body": ["#include <stdio.h>", "", "int main() {", " return 0;", "}"],
|
||||
"description": "Init file"
|
||||
},
|
||||
"Define function swap two var with macro": {
|
||||
"prefix": "fn_swap_macro",
|
||||
"body": ["#define swap(a, b) { typeof(a) temp = a; a = b; b = temp; }"],
|
||||
"description": "Define function swap two var with macro"
|
||||
},
|
||||
"Define function swap two int": {
|
||||
"prefix": "fn_swap",
|
||||
"body": [
|
||||
"void swap(int *a, int *b) {",
|
||||
" int temp = *a;",
|
||||
" *a = *b;",
|
||||
" *b = temp;",
|
||||
"}"
|
||||
],
|
||||
"description": "Define function swap two int"
|
||||
},
|
||||
"Define function put bool": {
|
||||
"prefix": "fn_putbool",
|
||||
"body": ["#define putbool(x) (printf(\"%s\", (x) ? \"TRUE\" : \"FALSE\"))"],
|
||||
"description": "Define function put bool"
|
||||
},
|
||||
"Define function max": {
|
||||
"prefix": "fake_max",
|
||||
"body": ["#define max(i, j) (((i) > (j)) ? (i) : (j))"],
|
||||
"description": "Define function max"
|
||||
},
|
||||
"Define function min": {
|
||||
"prefix": "fake_min",
|
||||
"body": ["#define min(i, j) (((i) < (j)) ? (i) : (j))"],
|
||||
"description": "Define function min"
|
||||
},
|
||||
"Fake loop": {
|
||||
"prefix": "fake_loop",
|
||||
"body": ["while (0) { // Fake loop", "}"],
|
||||
"description": "Fake loop"
|
||||
}
|
||||
}
|
23
0311-t/1.c
Normal file
23
0311-t/1.c
Normal file
@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void swap(char *a, char *b) {
|
||||
char temp = *a;
|
||||
*a = *b;
|
||||
*b = temp;
|
||||
}
|
||||
|
||||
int main() {
|
||||
char num[3];
|
||||
scanf("%s", num);
|
||||
|
||||
if (num[2] > num[1]) {
|
||||
swap(num + 2, num + 1);
|
||||
}
|
||||
if (num[1] > num[0]) {
|
||||
swap(num + 1, num);
|
||||
}
|
||||
if (num[2] > num[1]) {
|
||||
swap(num + 2, num + 1);
|
||||
}
|
||||
printf("%s\n", num);
|
||||
}
|
25
0311/1.c
25
0311/1.c
@ -1,23 +1,16 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void swap(char *a, char *b) {
|
||||
char temp = *a;
|
||||
*a = *b;
|
||||
*b = temp;
|
||||
}
|
||||
|
||||
int main() {
|
||||
char num[3];
|
||||
scanf("%s", num);
|
||||
|
||||
if (num[2] > num[1]) {
|
||||
swap(num + 2, num + 1);
|
||||
int m, n;
|
||||
scanf("%d %d", &m, &n);
|
||||
if (m % 2 != 0) {
|
||||
m++;
|
||||
}
|
||||
if (num[1] > num[0]) {
|
||||
swap(num + 1, num);
|
||||
if (n % 2 != 0) {
|
||||
n--;
|
||||
}
|
||||
if (num[2] > num[1]) {
|
||||
swap(num + 2, num + 1);
|
||||
while (0) {
|
||||
}
|
||||
printf("%s\n", num);
|
||||
printf("%d", (m + n) * (n - m + 2) / 2 / 2);
|
||||
return 0;
|
||||
}
|
10
0311/2.c
Normal file
10
0311/2.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int n, cnt = 0;
|
||||
scanf("%d", &n);
|
||||
printf("%d", (1 + n) * n / 2);
|
||||
return 0;
|
||||
while (0) {
|
||||
}
|
||||
}
|
11
0311/3.c
Normal file
11
0311/3.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int n, cnt = 0, i;
|
||||
scanf("%d", &n);
|
||||
for (i = 1; i <= n; i++) {
|
||||
cnt += (1 + i) * i / 2;
|
||||
}
|
||||
printf("%d", cnt);
|
||||
return 0;
|
||||
}
|
10
0311/4.c
Normal file
10
0311/4.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int i, cnt = 0;
|
||||
for (i = 1; i <= 597; i += 4) {
|
||||
cnt += i * (i + 2);
|
||||
}
|
||||
printf("%d", cnt);
|
||||
return 0;
|
||||
}
|
28
0311/5.c
Normal file
28
0311/5.c
Normal file
@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
void swap(int *a, int *b) {
|
||||
int temp = *a;
|
||||
*a = *b;
|
||||
*b = temp;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int m, n;
|
||||
scanf("%d %d", &m, &n);
|
||||
if (m > n) {
|
||||
swap(&m, &n);
|
||||
}
|
||||
if (m % 2 == 0) {
|
||||
m++;
|
||||
}
|
||||
if (n % 2 == 0) {
|
||||
n--;
|
||||
}
|
||||
if (m > n) {
|
||||
printf("0");
|
||||
return 0;
|
||||
}
|
||||
while (0) { // Fake loop
|
||||
}
|
||||
printf("%d", (m + n) * (n - m + 2) / 2 / 2);
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user