要啥数组啊

P1046 [NOIP2005 普及组] 陶陶摘苹果

quqi @ 2017-12-15 22:28:36

#include<iostream>
using namespace std;
int main()
{
int p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,h,y,count;
cin>>p1>>p2>>p3>>p4>>p5>>p6>>p7>>p8>>p9>>p10;
cin>>y;
count=0;
h=y+30;
if(h>=p1) count=count+1;
if(h>=p2) count=count+1;
if(h>=p3) count=count+1;
if(h>=p4) count=count+1;
if(h>=p5) count=count+1;
if(h>=p6) count=count+1;
if(h>=p7) count=count+1;
if(h>=p8) count=count+1;
if(h>=p9) count=count+1;
if(h>=p10) count=count+1;
cout<<count;
return 0;
}

by 衣帽间里的 @ 2018-01-20 19:28:38

“用数组可以使代码简洁”

也就是打起来不酸手


|