新增 260202/会场人数计算.cpp
This commit is contained in:
21
260202/会场人数计算.cpp
Normal file
21
260202/会场人数计算.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
//会场总共312人,第一排15人后一排比前一排多2人,求共有多少排,最后一排的人数。
|
||||
|
||||
1 #include<iostream>
|
||||
2 using namespace std;
|
||||
3
|
||||
4 int main(){
|
||||
5
|
||||
6 int p=1,x,sum;
|
||||
7 x=15;
|
||||
8 sum=x;
|
||||
9 while(sum<312){
|
||||
10 p+=1;
|
||||
11 x+=2;
|
||||
12 sum=sum+x;
|
||||
13
|
||||
14 cout<< "剧场有"<<p<<"排,"<<"最后一排有"<<x<<"人!"<<"共有"<<sum<<"人!"<<endl;
|
||||
15 }
|
||||
16
|
||||
17 return 0;
|
||||
18
|
||||
19 }
|
||||
Reference in New Issue
Block a user