Codechef Problems: Triangles (TRIANGLE7)
Problem Statement:
It is well known fact in mathematics that the sum of the angles in a triangle is degrees.
You had a triangle, but unfortunately you only remember the and angles of it, and you have forgotten the one.
Given that the first angle was , and the second was , can you figure out the third one? All angles are integers measured in degrees.
Input Format
- The first and only line of input contains integers - and .
Output Format
Print a single integer - the measure of the angle (in degrees).
Constraints
Solution:
Given,
A : First Angle of Triangle
B : Second Angle of Triangle
To find,
C : Third angle of Triangle
By Angle Sum property of Triangle,
A + B + C = 180'
C = 180 - (A + B)
Code Solution:
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << 180 - (a + b) << endl;
return 0;
}
Comments
Post a Comment