求大牛

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

榴莲君 @ 2017-04-22 20:31:08

----------#include<stdio.h>
#define maxn 14
int n[maxn];
int main()
{
    int a,b=0,c,d,e=0,f;
    while(scanf("%d",&a)==1  && b<9)
    n[b++] = a;
    scanf("%d",&c);
    f=c+30;
    while(b>-1)
    {
    if(n[b--]<=f)
    e++;
    }
    printf("%d\n",e);
    return 0;    
}
哎哎哎啊啊

by yzxbt @ 2017-05-06 23:26:17

#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv)
{
    int i,a[15]={},s,n;
    s=0;
    for(i=1;i<=10;i++)
      cin>>a[i];
    cin>>n;
    n+=30;
    for(i=1;i<=10;i++)
      if(a[i]<=n)
        s++;
    cout<<s<<endl;
    return 0;
}

|