C语言习题-指针

来源:百度知道 编辑:UC知道 时间:2024/07/05 07:27:23
下面程序的功能为:在a数组中查找与x值相同的元素的所在位置,用指针实现.请在____上补充完整
main()
{int a[6],x,y;
printf("\nInput 5 numbers:");
for (i=1;i<=5;i++) scanf("%d",a+i);
printf("\nInput x:");
scanf("%d",&x);
*a=x;____;
while (x!=*(a+i))
i--;
if(i>0) printf("%5d's position is:%4d\n",x,i);
else printf("%5d Not been found!\n",x);
}

main()
{int a[6],x,y;
printf("\nInput 5 numbers:");
for (i=1;i<=5;i++) scanf("%d",a+i);
printf("\nInput x:");
scanf("%d",&x);
*a=x;i=5;
while (x!=*(a+i))
i--;
if(i>0) printf("%5d's position is:%4d\n",x,i);
else printf("%5d Not been found!\n",x);
}

i=5