weixin_51083095
weixin_51083095
2021-01-15 15:35

c语言 编译错误compilation error

  • c语言

C: gcc 5.4.0

用clion和Xcode均可正常运行,但提交到acm网站上以后却显示Compilation error,我想知道是哪里出了问题,我应该如何修改方可通过?

1.代码如下:

 
#include <stdio.h>
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<n;i++)
        scanf("%d",&a[i]);
    for(j=n;j!=1;j--){//基本排序
        for(i=0;i<n-1;i++)
            if(a[i]>a[i+1]){t=a[i];a[i]=a[i+1];a[i+1]=t;}}
    for(j=0;j<m;j++){
        scanf("%d%d",&bb[j].x,&bb[j].y);
        for(o=0;o<n;o++)
            bb[j].w[o]=a[o];
    }//结构体建好了
    for(j=0;j<m;j++){
        k=bb[j].y;
        for(i=0;i<bb[j].x;i++)
        {
            bb[j].w[k]++;
            for(p=n-k;p!=1;p--){//循环排序
                for(q=0;q<p-1;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.详细错误输出:

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.测试数据如下:

样例输入:

5 3
1 1 1 1 1
3 2
1 1
2 4

样例输出: 

2
1
3
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

6条回答

为你推荐

换一换