微信搜索关注"91考试网"公众号,领30元,获取公务员、事业编、教师等考试资料40G!
{
Int a[30],x=5,h; (假设a数组元素已经有值)
h=Search(a,x);
if(h==-1)
printf(“%d isn’t in a”,x);
else
printf(“%d is in the position of %d”,x,h);
}
Int search(int *a,int x)
{
Int I;
For(i=0;i<30;i++)
If(a[i]==x)
Return I;
Return -1;
}
题目:编写函数给5X6的二维数组赋10-40的随机整数
Void getdata(int a[5][6])
{
Int I,j,x;
For(i=0;i<5;i++)
For(j=0;j<6;j++)
{
While(!((x=rand()%41)/10));
a[i][j]=x;
}