Files
homework/260202/会场人数计算.cpp

21 lines
477 B
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//会场总共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 }