Problem Description

Z先生是一個大牧場主,他飼養的奶牛每年都源源不斷地運往世界各地,我們的故事也由此產生了…… Z先生有一個矩形牧場,它的長和寬分別用a 和b (單位:米)表示,現在需要再牧場四周修建圍欄,請編一個程序計算牧場的周長以確定用料的多少。

Input Format

輸入檔有多組數據,每組數據佔一行,分別為a 和b ,以一個空格隔開。 a 和b 均為不超過1000的正整數。

Output Format

輸出牧場的周長。

Sample Input

4     3

Sample Output

14

-----*Problem from【ZeroJudge, An Online Judge System For Beginners

 

My Answer

1. 2. 3. 4. 5. 6. 7. 8. 9. 10.#include<iostream> using namespace std; int main(void) {    int a, b;    while(cin>>a>>b){       cout<<a*2+b*2<<endl;    }    return 0; }

 

文章標籤