gpt4 book ai didi

c - 测试 - 运行时错误 SIGSEGV

转载 作者:行者123 更新时间:2023-11-30 18:46:32 25 4
gpt4 key购买 nike

请帮助我Here is a problem of Codechef 。这是我的提交内容:

#include <stdio.h>

#define M 60

int main()
{
int i,arr[M],input;
int s=0;
puts("Input:");
for(i=0;;i++){
scanf("%d",&input);
if(input==42){
scanf("%d");
break;
}
else{
arr[i]=input;
s++;
}
}
puts("Output:");
for(i=0;i<s;i++){
printf("%d\n",arr[i]);
}
return 0;
}

当我创建代码时,它在 GCC 4.9.2 上成功运行,但是当我提交此代码时,Codechef 说它有运行时错误。我尝试过但找不到错误。所以请帮我找出错误...

最佳答案

第二个 scanf 中的变量丢失

关于c - 测试 - 运行时错误 SIGSEGV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50823353/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com