1.5 08: Sum of interior angles of polygons

Description
In Euclidean geometry, the sum of the interior angles of an n-sided polygon is (n-2)*180°. Knowing the degree of (n-1) internal angles, the degree of the remaining unknown internal angle can be calculated. Please write a program to solve this problem.

Input The
first line has only one integer n (2 The second line has (n-1) positive integers, which are the degrees of each known internal angle. Two adjacent integers are separated by a single space. The
data guarantees a given polygon Legal.
Output
a positive integer, which is the degree of the unknown internal angle.
Input
3
45 60 for example

Sample output
75

#include <iostream>
using namespace std;
int main()
{
    
    
	int n, r, sum=0, temp;
	cin >> n;
	for(int i=1;i<n;i++)
	{
    
    
		cin>>temp;
		sum+=temp;
	}
	r = (n-2)*180-sum;
	cout<<r<<endl;
	return 0;
}

Guess you like

Origin blog.csdn.net/yansuifeng1126/article/details/111994206