FINDTRIANGLE

PROBLEM LINK:

Practice
Author: RushikeshThakare
Tester: NilprasadBirajdar
Editorialist: Yogeshdeolalkar

DIFFICULTY:

CAKEWALK, SIMPLE.

PREREQUISITES:

None

PROBLEM:

Yogesh knows the all types of triangle. But problem is that when teacher give him a task to find out what is a type triangle it is , after showing him triangle with a side , he was unable to recognised which type of triangle it was. So help him to find which type of triangle it is.

For example , teacher give him a triangle whose all sides are equal , then it is equilateral triangle.

Your task is to print which type of traingle it is

  • Equilateral
  • Isosceles or
  • Scalene

QUICK EXPLANATION:

output in a single line print type of triangle ie. Equilateral, Isosceles or Scalene

SOLUTIONS:

Setter's Solution

#include
using namespace std;

int main()
{
int T,A,B,C;
cin>>T;
for(int i=1;i<=T;i++){
cin>>A;
cout<<endl;
cin>>B;
cout<<endl;
cin>>C;
cout<<endl;

if(A == B && B == C)
{
	cout << "\nEquilateral";
}
else if(A == B || B == C || A == C)
{
	cout << "\nIsosceles";
}
else
	cout << "\nScalene";

}
return 0;
}

Tester's Solution

#include <stdio.h>

int main(void)
{
int a,b,c,t;
scanf(“%d”,&t);

for(int k=0;k<t;k++)
{
scanf(“%d %d %d”,&a,&b,&c);
if(a==b && b==c)
{
printf(“Equilateral\n”);
}
else if(a==b || b==c || c==a)
{
printf(“Isosceles\n”);
}
else
{
printf(“Scalene\n”);
}
}
return 0;
}

Editorialist's Solution

#include <stdio.h>

int main(void)
{
int t;
scanf(“%d”, &t);
while(t–>0)
{
int a, b, c;
scanf(“%d %d %d”, &a, &b, &c);
if(a==b && b==c && c==a)
{
printf(“Equilateral\n”);
}
else if(a==b && b!=c && a!=c)
{
printf(“Isosceles\n”);
}
else if(b==c && c!=a && b!=a)
{
printf(“Isosceles\n”);
}
else if(a==c && c!=b && a!=b)
{
printf(“Isosceles\n”);
}
else if(a!=b && b!=c && c!=a)
{
printf(“Scalene\n”);
}

}

// your code goes here
return 0;

}