55 lines
1.8 KiB
C
55 lines
1.8 KiB
C
#include <stdio.h>
|
|
#include "libs.h"
|
|
//---------------------------------------------------------------------------------------
|
|
// Exercise 2
|
|
// ----------
|
|
//
|
|
// General : The program recognize if is it triangles and the type of triangle.
|
|
//
|
|
// Input : 3 numbers.
|
|
//
|
|
// Process : The program recognize by angles if is it triangles and the type of triangle.
|
|
//
|
|
// Output : '0' - is not a triangle.
|
|
// '1' - is sharp angled triangle.
|
|
// '2' - is right angled triangle.
|
|
// '3' - is blunt angled triangle.
|
|
//
|
|
//---------------------------------------------------------------------------------------
|
|
// Programmer : Cohen Idan
|
|
// Student No : None
|
|
// Date : 12.09.2019
|
|
//---------------------------------------------------------------------------------------
|
|
void main(void)
|
|
{
|
|
unsigned short angle1,
|
|
angle2,
|
|
angle3,
|
|
max_angle,
|
|
sum_angles,
|
|
type_triangle = ZERO;
|
|
printf("Enter 3 angels: ");
|
|
scanf("%hu%hu%hu", &angle1, &angle2, &angle3);
|
|
|
|
sum_angles = angle1 + angle2 + angle3;
|
|
if (sum_angles == SUM_OF_ANGLES_IN_A_TRIANGLE)
|
|
{
|
|
max_angle = angle1;
|
|
max_angle = MAX(MAX(max_angle, angle2), angle3);
|
|
type_triangle = SHARP_ANGLED_TRIAMGLE;
|
|
if (max_angle == RIGHT_ANGLE)
|
|
{
|
|
type_triangle = RIGHT_ANGLED_TRIAMGLE;
|
|
if (max_angle > RIGHT_ANGLE)
|
|
{
|
|
type_triangle = BLUNT_ANGLED_TRIAMGLE;
|
|
}
|
|
}
|
|
}
|
|
|
|
printf("If you got '0' - is not a triangle.\n\
|
|
If you got '1' - is sharp angled triangle.\n\
|
|
If you got '2' - is right angled triangle.\n\
|
|
If you got '3' - is blunt angled triangle.\n\
|
|
Triangle: %hu\n", type_triangle);
|
|
} |