作者:髻续儛动 | 来源:互联网 | 2023-08-15 11:09
C: gcc 5.4.0
用clion和Xcode均可正常运行,但提交到acm网站上以后却显示Compilation error,我想知道是哪里出了问题,我应该如何修改方可通过?
1.代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #include
typedef struct {
int x;
int y;
int w[100000];
}ask;
ask bb[100000];
int main(){
int n,m,i,j,p,q,o,k,t,a[100000];
scanf("%d%d",&n,&m);
for(i=0;i scanf("%d",&a[i]);
for(j=n;j!=1;j--){//基本排序
for(i=0;i if(a[i]>a[i+1]){t=a[i];a[i]=a[i+1];a[i+1]=t;}}
for(j=0;j scanf("%d%d",&bb[j].x,&bb[j].y);
for(o=0;o bb[j].w[o]=a[o];
}//结构体建好了
for(j=0;j k=bb[j].y;
for(i=0;i {
bb[j].w[k]++;
for(p=n-k;p!=1;p--){//循环排序
for(q=0;q if(bb[j].w[k]>bb[j].w[k+1])
{t=bb[j].w[k];bb[j].w[k]=bb[j].w[k+1];bb[j].w[k+1]=t;}}
}
printf("%d\n",bb[j].w[k]);
}
return 0;
} |
2.详细错误输出:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Main.c: In function ‘main’:
Main.c:9:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
^
Main.c:11:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&a[i]);
^
Main.c:16:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&bb[j].x,&bb[j].y);
^
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-start.o): In function `generic_start_main':
(.text+0x83): relocation truncated to fit: R_X86_64_PC32 against symbol `_dl_phdr' defined in COMMON section in /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(dl-support.o)
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-start.o): In function `generic_start_main':
(.text+0xc7): relocation truncated to fit: R_X86_64_PC32 against symbol `_dl_phdr' defined in COMMON section in /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(dl-support.o)
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-start.o): In function `generic_start_main':
(.text+0xd5): relocation truncated to fit: R_X86_64_PC32 against symbol `_dl_phnum' defined in COMMON section in /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(dl-support.o)
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-start.o): In function `generic_start_main':
(.text+0x13e): relocation truncated to fit: R_X86_64_PC32 against symbol `_dl_osversion' defined in COMMON section in /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(dl-support.o)
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-start.o): In function `generic_start_main':
(.text+0x14c): relocation truncated to fit: R_X86_64_PC32 against symbol `_dl_osversion' defined in COMMON section in /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(dl-support.o)
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-tls.o): In function `__libc_setup_tls':
(.text+0x14): relocation truncated to fit: R_X86_64_PC32 against symbol `_dl_phdr' defined in COMMON section in /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(dl-support.o)
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-tls.o): In function `__libc_setup_tls':
(.text+0x20): relocation truncated to fit: R_X86_64_PC32 against symbol `_dl_phnum' defined in COMMON section in /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(dl-support.o)
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-tls.o): In function `__libc_setup_tls':
(.text+0xac): relocation truncated to fit: R_X86_64_PC32 against symbol `_dl_static_dtv' defined in COMMON section in /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-tls.o)
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-tls.o): In function `__libc_setup_tls':
(.text+0xf4): relocation truncated to fit: R_X86_64_PC32 against symbol `_dl_static_dtv' defined in COMMON section in /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-tls.o)
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-tls.o): In function `__libc_setup_tls':
(.text+0xff): relocation truncated to fit: R_X86_64_PC32 against symbol `_dl_static_dtv' defined in COMMON section in /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-tls.o)
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libc.a(libc-tls.o): In function `__libc_setup_tls':
(.text+0x11f): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status |
3.测试数据如下:
样例输入:
1 2 3 4 5
| 5 3
1 1 1 1 1
3 2
1 1
2 4 |
样例输出:
你的结构体分配内存100 * 1000 = 100k,然后你又定义了一个100 * 1000 = 100k大小的数组,总的内存空间是:10 * 1000 * 1000 * 1000 * sizeof(int) = 40g 大概这么大,内存怎么可能够。把这两个数组改小点应该就没问题了。