progress
This commit is contained in:
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;
|
||||
}
|
||||
Reference in New Issue
Block a user