Topic background
Once a year the summer camp starts again, Kakashi and the small partners have already prepared, is filled with anticipation this joyful journey. In a sunny morning, kakashi under the leadership of the teacher came to the first stop of the summer camp-"Magic wood processing plant."
Title Description
This wood processing plant is very special, the workers only made
As round and rectangular planks, the factory's measuring workers need to calculate the area of each finished plank every day
In order to count the amount of wood used. If it is a circular plank, they only need to measure the length of the radius;
If it is a rectangular plank, only the length of the two sides (in centimeters) needs to be measured. To the worker Master
, measuring is a simple matter, but calculating the plank area is a repetitive and tedious thing,
Looking at the measurement of the workers ' faces, Kakashi anxious, dear children, can you help
Help Kaka West, to measure the workers to solve this problem?
Input/output format
Input format:
Input: There are two lines of input data. The first line is a positive integer m, which represents the measured plank shape (1 indicates the circle
The second line has several numbers, if m=1, the second line gives the circular
Radius A (Specify PI to take 3.14); if m=2, the second line gives the rectangle length and width, A, a, b
(The middle is separated by a space).
Output format:
Output: Plank area. (The final output is rounded to 2 digits after the decimal point)
Input and Output Sample input example # #:
Sample # # of output:
Output 1: (area.out) 28.26
Input Sample #:
Output Example #:
Output 2: (area.out) 12.00
Description
Data range:
0≤ Plank Edge Length or radius ≤500
——————————————————————————————————————————————————————
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6#include <queue>7#include <cstdlib>8 using namespacestd;9 intRead () {Ten intx=0, f=1;CharCh=GetChar (); One while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} A while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} - returnx*F; - } the voidCircle (); - voidSquare (); - intMain () - { +Std::ios::sync_with_stdio (false); - intn,m; +Cin>>N; A if(n==1) circle (); at if(n==2) square (); - return 0; - } - voidCircle () - { - Doublea,s; inCin>>A; -s=3.14*a*A; toprintf"%.2f", s); + return; - } the voidSquare () * { $ Doublea,b,s;Panax NotoginsengCin>>a>>b; -s=a*b; theprintf"%.2f", s); + return; A}View Code
Rokua U2641 Wood (area)--s.b.s.