三角形

 avatar
user_6817964
c_cpp
3 years ago
919 B
6
Indexable
#include <stdio.h> // printf
int main()
{
	int s[3];
	scanf_s("%d%d%d", &s[0], &s[1], &s[2]);
	for (int i = 2, k = 2; k > 0; k--) {
		for (int j = i; j > 0; j--) {
			if (s[j] < s[j - 1]) {
				int temp = s[j];
				s[j] = s[j - 1];
				s[j - 1] = temp;
			}
		}
	}
	/*printf("%d%d%d", s[0], s[1], s[2]);*/
	if (s[0] == s[1] && s[1] == s[2])
		printf("regular triangle");
	else if (s[0] + s[1] <= s[2])
		printf("not a triangle");
	else if (s[0] * s[0] + s[1] * s[1] == s[2] * s[2])
		printf("rectangular triangle");
	else if (s[0] * s[0] + s[1] * s[1] < s[2] * s[2] && s[0] == s[1])
		printf("isosceles obtuse triangle");
	else if (s[0] * s[0] + s[1] * s[1] > s[2] * s[2] && s[1] == s[2])
		printf("isosceles acute triangle");
	else if (s[0] * s[0] + s[1] * s[1] < s[2] * s[2])
		printf("obtuse triangle");
	else if (s[0] * s[0] + s[1] * s[1] > s[2] * s[2])
		printf("acute triangle");
	
}
Editor is loading...