三辺を入力して、正三角形、二等辺三角形、三辺の長さが違う三角形の判断を行うプログラムを作りたいです。
どんな値を入力しても正三角形と表示されてしまいます。このプログラムの何がおかしいのでしょうか?行き詰ってしまったので教えてください。
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int main(void) { int a, b, c; printf("Input the lenghts of the sides of the triangle: "); while (1) { scanf("%lf", &a); scanf("%lf", &b); scanf("%lf", &c); if ((a == b) && (b == c)) { printf("3 (equilateral)\n"); } else if ((a == b || a == c || b == c)) { printf("2 (isosceles)\n"); } else if (a + b >= c && b + c >= a && c + a >= b) { if (a != b != c) { printf("1 (scalene)\n"); } } else if (a + b<c || a + c<b || b + c<a) { printf("0 (not a valid triangle)\n"); } return(0); } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/28 16:52
2018/04/28 17:25
2018/04/28 17:38