Valid Triangles ( CodeChef Problem code: FLOW013 )
PROBLEM :
Write a program to check whether a triangle is valid or not, when the three angles of the triangle
are the inputs. A triangle is valid if the sum of all the three angles is equal to 180 degress.
Input
The first line contains an integer T, total number of testcases. Then follow T lines, each line contains three angles A, B and C of triangle separated by space.
Output
Display 'YES' or 'NO' if the triangle is Valid or not respectively.
Constraints
1 = T = 1000
40 = A,B,C = 180
Example
Input
3
30 40 110
45 45 90
180 0 0
Output
YES
YES
NO
--------------------------------------------------------------------------------
SIMPLE c++ IMPLEMENTATION :
--------------------------------------------------------------------------------
#include<iostream>
using namespace std ;
int main()
{
int t,a,b,c ;
cin>>t ;
while(t--)
{
cin>>a>>b>>c ;
if(a+b+c==180)
cout<<"YES" ;
else
cout<<"NO" ;
cout<<endl ;
}
return 0 ;
}
---------------------------------------------------------------------------------
Write a program to check whether a triangle is valid or not, when the three angles of the triangle
are the inputs. A triangle is valid if the sum of all the three angles is equal to 180 degress.
Input
The first line contains an integer T, total number of testcases. Then follow T lines, each line contains three angles A, B and C of triangle separated by space.
Output
Display 'YES' or 'NO' if the triangle is Valid or not respectively.
Constraints
1 = T = 1000
40 = A,B,C = 180
Example
Input
3
30 40 110
45 45 90
180 0 0
Output
YES
YES
NO
--------------------------------------------------------------------------------
SIMPLE c++ IMPLEMENTATION :
--------------------------------------------------------------------------------
#include<iostream>
using namespace std ;
int main()
{
int t,a,b,c ;
cin>>t ;
while(t--)
{
cin>>a>>b>>c ;
if(a+b+c==180)
cout<<"YES" ;
else
cout<<"NO" ;
cout<<endl ;
}
return 0 ;
}
---------------------------------------------------------------------------------
Comments
Post a Comment