#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[])
{
int a[10]={0,1,2,3,4,5,6,7,8,9};
int num,i,b;
printf("请输入一个数字:\n");
scanf("%d",&num);
for(i=0;i<=10;i++)
{
b=((num=a[i])?1:2);
if(b==1)
{
printf("%d在数组中\n",num);
}
else if(b==2)
{
printf("%d不在数组中\n",num);
}
}
return 0;
}
请问一下这个程序还有哪错了,真的看不出来了
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
4条回答 默认 最新
CSDN专家-link 2021-11-27 16:37关注最好自己有初步的分析,以及谁告诉你代码有错,有什么错误现象
第14行循环应该是i<10,不能i<=10
i=10时会数组越界访问本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报 编辑记录解决 1无用