progress
This commit is contained in:
10
programs/a1/info.json
Normal file
10
programs/a1/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "課題1",
|
||||
"description": "入力した整数値が1桁の自然数に含まれるかを判定するプログラム。",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/a1.png"
|
||||
},
|
||||
"note": ""
|
||||
}
|
||||
BIN
programs/a1/main
Executable file
BIN
programs/a1/main
Executable file
Binary file not shown.
16
programs/a1/main.c
Normal file
16
programs/a1/main.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int n;
|
||||
|
||||
printf("Input integer: ");
|
||||
scanf("%d", &n);
|
||||
|
||||
if (n <= 10 && n > 0) {
|
||||
printf("%d is one digit natural number.\n", n);
|
||||
} else {
|
||||
printf("%d is not one digit natural number.\n", n);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
10
programs/a2/info.json
Normal file
10
programs/a2/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "課題2",
|
||||
"description": "入力した3つの整数値が小さい順または等価になっているかを検証するプログラム。",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/a2.png"
|
||||
},
|
||||
"note": ""
|
||||
}
|
||||
BIN
programs/a2/main
Executable file
BIN
programs/a2/main
Executable file
Binary file not shown.
24
programs/a2/main.c
Normal file
24
programs/a2/main.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int a, b, c;
|
||||
|
||||
printf("Input integer #1: ");
|
||||
scanf("%d", &a);
|
||||
printf("Input integer #2: ");
|
||||
scanf("%d", &b);
|
||||
printf("Input integer #3: ");
|
||||
scanf("%d", &c);
|
||||
|
||||
if (a <= b) {
|
||||
if (b <= c) {
|
||||
puts("OK");
|
||||
} else {
|
||||
puts("NG");
|
||||
}
|
||||
} else {
|
||||
puts("NG");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
10
programs/a3/info.json
Normal file
10
programs/a3/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "課題3",
|
||||
"description": "二次方程式の解の種類を判別するプログラム。",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/a3.png"
|
||||
},
|
||||
"note": "上記のコードリストは浮動少数点数の演算・変数格納時の誤差を考慮していない。\\n考慮する場合は\\\\texttt{float.h}内の\\\\texttt{DBL_MIN}や\\\\texttt{DBL_EPSILON}を用いた判別処理が必要である。"
|
||||
}
|
||||
BIN
programs/a3/main
Executable file
BIN
programs/a3/main
Executable file
Binary file not shown.
24
programs/a3/main.c
Normal file
24
programs/a3/main.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
double a, b, c, D;
|
||||
|
||||
printf("a: ");
|
||||
scanf("%lf", &a);
|
||||
printf("b: ");
|
||||
scanf("%lf", &b);
|
||||
printf("c: ");
|
||||
scanf("%lf", &c);
|
||||
|
||||
D = b * b - 4 * a * c;
|
||||
|
||||
if (D == 0.0) {
|
||||
puts("Superposition");
|
||||
} else if (D < 0.0) {
|
||||
puts("Two complex answers");
|
||||
} else if (D > 0.0) {
|
||||
puts("Two real answers");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
10
programs/a4/info.json
Normal file
10
programs/a4/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "課題4",
|
||||
"description": "1年の月の日数を返すプログラム。",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/a4.png"
|
||||
},
|
||||
"note": ""
|
||||
}
|
||||
BIN
programs/a4/main
Executable file
BIN
programs/a4/main
Executable file
Binary file not shown.
29
programs/a4/main.c
Normal file
29
programs/a4/main.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int month;
|
||||
|
||||
printf("Input month: ");
|
||||
scanf("%d", &month);
|
||||
|
||||
if (month < 1 || month > 12) {
|
||||
puts("Unknown month");
|
||||
return 1;
|
||||
}
|
||||
|
||||
switch (month) {
|
||||
case 2:
|
||||
puts("28 days");
|
||||
break;
|
||||
case 4:
|
||||
case 6:
|
||||
case 9:
|
||||
case 11:
|
||||
puts("30 days");
|
||||
break;
|
||||
default:
|
||||
puts("31 days");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
10
programs/a5/info.json
Normal file
10
programs/a5/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "課題5",
|
||||
"description": "第10回の課題「簡易電卓」を繰り返し計算できるように変更したプログラム。",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/a5.png"
|
||||
},
|
||||
"note": ""
|
||||
}
|
||||
BIN
programs/a5/main
Executable file
BIN
programs/a5/main
Executable file
Binary file not shown.
54
programs/a5/main.c
Normal file
54
programs/a5/main.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define ADD 1
|
||||
#define SUB 2
|
||||
#define MUL 3
|
||||
#define DIV 4
|
||||
|
||||
int main(void) {
|
||||
double a, b;
|
||||
int op;
|
||||
int retry = 1;
|
||||
|
||||
do {
|
||||
printf("Input first number: ");
|
||||
scanf("%lf", &a);
|
||||
printf("Input second number: ");
|
||||
scanf("%lf", &b);
|
||||
|
||||
printf("Select Operation:\n"
|
||||
"[1]: Addition\n"
|
||||
"[2]: Subtraction\n"
|
||||
"[3]: Multiplication\n"
|
||||
"[4]: Division\n"
|
||||
"> ");
|
||||
scanf("%d", &op);
|
||||
|
||||
switch (op) {
|
||||
case ADD:
|
||||
printf("ANS: %lf\n", a + b);
|
||||
break;
|
||||
case SUB:
|
||||
printf("ANS: %lf\n", a - b);
|
||||
break;
|
||||
case MUL:
|
||||
printf("ANS: %lf\n", a * b);
|
||||
break;
|
||||
case DIV:
|
||||
if (b == 0.0) {
|
||||
puts("Zero Division");
|
||||
return 1;
|
||||
}
|
||||
printf("ANS: %lf\n", a / b);
|
||||
break;
|
||||
default:
|
||||
puts("Undefined Operation");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Retry? [1/0]: ");
|
||||
scanf("%d", &retry);
|
||||
} while (retry == 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user