#include <stdio.h>//本題目卡住的點:1.邏輯問題 2.對if-else if-else結構的運行理解,導致了邏輯混亂//注意:程序會組個判斷,只要寫出每一個情況,只要符合了就會執行,同時注意換行輸出int main()
{int arr[3];int temp;for (int i = 0; i < 3; i++){scanf("%d", &arr[i]);}for (int i = 0; i < 2; i++){for (int j = 0; j < 2 - i; j++){if (arr[j] > arr[j + 1]){temp = arr[j];arr[j] = arr[j + 1];arr[j + 1] = temp;}}}int a, b, c;a = arr[0];b = arr[1];c = arr[2];if (a + b <= c){printf("Not triangle\n");}else{if (a * a + b * b == c * c){printf("Right triangle\n");}else if (a * a + b * b > c * c){printf("Acute triangle\n");}else if (a * a + b * b < c * c){printf("Obtuse triangle\n");}//理解這里單獨使用if的原因:在else if中如果有條件符合了就不會繼續往下執行if (a == b || b == c || a == c) //排序了,a==c可以不用寫,但是等邊也是特殊的等腰三角形,符合情況{printf("Isosceles triangle\n");}if (a == b && b == c){printf("Equilateral triangle\n");}}return 0;
}