// C08_Ex 9: Input 3 whole number.
// 3 This is an integer form three sides of a triangle or not ?
// If so, what is the triangle?
#include <stdio.h>
void main()
{
int a, b, c;
printf("Input 3 whole number: ");
scanf("%d%d%d", &a, &b, &c);
if (a + b > c && a + c > b && b + c > a)
{
// This is the 3 sides of a triangle
if (a == b && b == c)
printf("=> This is an equilateral triangle\n");
else
{
if (a == b || b == c || c == a)
printf("=> This is an isosceles triangle\n");
else
{
if (a*a + b*b == c*c || b*b + c*c == a*a || c*c + a*a == b*b)
printf("=> This is a right triangle\n");
else
printf("=> This is a regular triangle\n");
}
}
}
else
printf("=> This is not the three sides of a triangle\n");
}
// 3 This is an integer form three sides of a triangle or not ?
// If so, what is the triangle?
#include <stdio.h>
void main()
{
int a, b, c;
printf("Input 3 whole number: ");
scanf("%d%d%d", &a, &b, &c);
if (a + b > c && a + c > b && b + c > a)
{
// This is the 3 sides of a triangle
if (a == b && b == c)
printf("=> This is an equilateral triangle\n");
else
{
if (a == b || b == c || c == a)
printf("=> This is an isosceles triangle\n");
else
{
if (a*a + b*b == c*c || b*b + c*c == a*a || c*c + a*a == b*b)
printf("=> This is a right triangle\n");
else
printf("=> This is a regular triangle\n");
}
}
}
else
printf("=> This is not the three sides of a triangle\n");
}
0 Comments:
Post a Comment