无法打开文件是什么错误啊

P1478 陶陶摘苹果(升级版)

director_yu @ 2019-12-22 11:25:56

编译失败总说 No valid executable file was produced by the compiler怎么解觉啊大佬求助```c

include<stdio.h>

int mian() { int i,n,p,a,b,j,item; int xy[1000][2]; scanf("%d%d" ,&n,&p); getchar(); scanf("%d%d",&a,&b); getchar(); for(i=0;i<n;i++) scanf("%d%d",&xy[i][0],&xy[i][1]); for(j=0;j<n;j++) for(i=0;i<n-j;i++){ if(xy[i][1]>xy[i+1][1]){ xy[i][1]=item; xy[i][1]=xy[i+1][1]; xy[i+1][1]=item; xy[i][0]=item; xy[i][0]=xy[i+1][0]; xy[i+1][0]=item; } } for(i=0;i<n;i++) { if(xy[i][0]<=a+b) p-=xy[i][1]; if(p<0) break; } printf("%d",i); return 0; }


by 百因必有AC @ 2019-12-22 11:26:58

不加缩进和换行害死人


by 百因必有AC @ 2019-12-22 11:27:14

拜托换一下行好吗


by 百因必有AC @ 2019-12-22 11:27:18

@director_yu


by 百因必有AC @ 2019-12-22 11:27:33

眼都看瞎了


by Hydrate @ 2019-12-22 11:27:53

@director_yu

int mian()


by 百因必有AC @ 2019-12-22 11:28:38

主函数名写错了@director_yu


by director_yu @ 2019-12-22 11:29:07

#include<stdio.h>
int mian()
{
    int i,n,p,a,b,j,item;
    int xy[1000][2];
    scanf("%d%d" ,&n,&p);
    getchar();
    scanf("%d%d",&a,&b);
    getchar();
    for(i=0;i<n;i++)
        scanf("%d%d",&xy[i][0],&xy[i][1]);
    for(j=0;j<n;j++)
        for(i=0;i<n-j;i++){
            if(xy[i][1]>xy[i+1][1]){
                xy[i][1]=item;
                xy[i][1]=xy[i+1][1];
                xy[i+1][1]=item;
                xy[i][0]=item;
                xy[i][0]=xy[i+1][0];
                xy[i+1][0]=item;
            }
        }
        for(i=0;i<n;i++)
        {
            if(xy[i][0]<=a+b)
            p-=xy[i][1];
            if(p<0)
            break;
        }
        printf("%d",i);
        return 0;
}

大体思路是对体力值先倒序排序然后遍历


by director_yu @ 2019-12-22 11:29:49

@北辰yama 我是菜鸡“嘤嘤嘤”


by 百因必有AC @ 2019-12-22 11:30:18

@director_yu

应该是

\color{red}\text{int main}

by 百因必有AC @ 2019-12-22 11:31:26

一道红题你用遍历做,真是醉了@director_yu


| 下一页