ORZ水题大法好!!!!

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

ChordMaster @ 2017-10-11 17:20:23

#include<bits/stdc++.h>
using namespace std;
int main(){
    int num=0;
    int a,b,c,d,e,f,g,h,i,j,k;
    cin>>a>>b>>c>>d>>e>>f>>g>>h>>i>>j;
    cin>>k;
    k=k+30;
    if(a<=k) num=num+1;
    if(b<=k) num=num+1;
    if(c<=k) num=num+1;
    if(d<=k) num=num+1;
    if(e<=k) num=num+1;
    if(f<=k) num=num+1;
    if(g<=k) num=num+1;
    if(h<=k) num=num+1;
    if(i<=k) num=num+1;
    if(j<=k) num=num+1;
    cout<<num;
return 0;
}

by vani_prcups @ 2017-10-11 18:44:31

觉得你要么是初学者,要么是不想刷NOI+的dalao……


by ChordMaster @ 2017-10-12 21:16:16

ORZ不,我是萌新!!!!


by Sakura_Peng @ 2017-10-15 22:04:09

@NPC1 emm这道题明明是可以开a[10]的数组的啊=-=这样不麻烦吗?


by pengja @ 2017-10-16 21:11:40

@陈智鹏_peng_ 他应该是不会开数组吧


by pengja @ 2017-10-16 21:12:28

你的num=num+1也可以改成num++


by ChordMaster @ 2017-10-23 14:48:51

ORZ写大佬指教,这样一改如何???

#include<bits/stdc++.h>
using namespace std;
int ans[12];
int main(){
    int num;
    int vs;
    for(int i=1;i<=10;i++)
    cin>>ans[i];
    cin>>vs;
    vs+=30;
    for(int j=1;j<=10;j++)
    num+=!(ans[j]>vs);
    cout<<num;
return 0;
}

|