多邊形內角和

題目描述

在歐幾里德幾何中,n 邊形的內角和是 (n−2)×180°

小蒜蒜已經知道其中 (n−1) 個內角的度數,請編寫一個程序,計算出剩下的一個未知內角的度數。

輸入格式

 1 行只有一個整數 n (3≤n≤20)

 2 行有 (n−1) 個正整數,是每個已知內角的度數。相鄰兩個整數之間用單個空格隔開。

數據保證給定多邊形合法。

輸出格式

一個正整數,爲未知內角的度數。

輸出時每行末尾的多餘空格,不影響答案正確性

樣例輸入

3

45 60

樣例輸出

75


	public static void main(String[] args) {
		Scanner s =new Scanner (System.in);
		int n=s.nextInt();
		int a[] =new int [n-1];
		for(int i=0;i<a.length;i++) {
			a[i] =s.nextInt();
		}
		int deg =(n-2)*180;
		for(int i=0;i<a.length;i++) {
			deg -=a[i];
		}
		System.out.println(deg);
	}

過於簡單,不做過多描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章