谁能帮我一下?

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

zoushengsheng @ 2024-07-22 10:51:11

#include<cstdio>
int main(){int k,a,b,n=10;scanf("%d",&k);for(register long long i=1;i++;i<=10){scanf("%d",&a);scanf("%d",&k);}printf("%d",b);}

by chen_z @ 2024-07-22 10:54:03

@zoushengsheng 你为啥要把代码全压在第二行啊?


by chen_z @ 2024-07-22 10:55:46

展开了这是个啥(汗

#include<cstdio>
int main(){
    int k,a,b,n=10;
    scanf("%d",&k);
    for(register long long i=1;i++;i<=10){
        scanf("%d",&a);
        scanf("%d",&k);
    }
    printf("%d",b);
}

by chen_z @ 2024-07-22 10:56:31

你认真求助来的吗? @zoushengsheng


by zoushengsheng @ 2024-07-22 10:56:59

帮我把scanf("%d",&k)弄到后面并且不会TLE呗
求求了。

by zoushengsheng @ 2024-07-22 11:00:58

#include<cstdio>
int main(){int k,a,b,;scanf("%d",&k);for(int i=1;i++;i<=10){scanf("%d",&a);if(k+30>=a) b++;}printf("%d",b);}

by Xingyi_2014 @ 2024-07-28 11:41:58

#include <bits/stdc++.h>
using namespace std;
int height,a[10],x,sum;
int main(){
    for(int i=0;i<10;i++){
        cin>>a[i];
    }
    cin>>height;
    x=height+30;
    for(int i=0;i<10;i++){
        if(a[i]<=x) sum++;  
    }
    cout<<sum;
    return 0;
}

by xumingyang666 @ 2024-08-11 23:09:50

代码格式稀烂,看不懂


by ShadowAbyss @ 2024-08-13 23:08:15

@zoushengsheng

#include <cstdio>
int main() {
    int k = 0, a[10], b = 0;
    int i = 0;

    for (i = 0;  i < 10; i++) {//输入苹果的高度
        scanf("%d", &a[i]);
    }

    scanf("%d", &k);//输入陶陶不用凳子所够到的最大高度

    for (i = 0; i < 10; i++) {
        if (k + 30 >= a[i]) {
            b++;
        }
    }

    printf("%d", b);
    return 0;
}

|