Triangle Detection C Program & Guide
Here is a simple C program for determining the type of a triangle:
#include <stdio.h>
int main() {
int side1, side2, side3;
printf("请输入三角形的三条边长:\n");
scanf("%d %d %d", &side1, &side2, &side3);
if(side1 + side2 > side3 && side1 + side3 > side2 && side2 + side3 > side1) {
if(side1 == side2 && side2 == side3) {
printf("这是一个等边三角形。\n");
}
else if(side1 == side2 || side1 == side3 || side2 == side3) {
printf("这是一个等腰三角形。\n");
}
else {
printf("这是一个普通三角形。\n");
}
}
else {
printf("这不是一个三角形。\n");
}
return 0;
}
After running the program, it will prompt the user to enter the lengths of the three sides of a triangle, then determine the type of triangle based on the input lengths, and output the corresponding result.