例如:若a所指数组中的数据依次为:1、2、3、4、5、6、7、8、9,则调换后
为:6、7、8、9、5、1、2、3、4。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。 不得增行或删行,也不得更改程序的结构!
给定源程序:
#include
#define N 9
void fun(int a[], int n)
{int i, t, p;
/**********found**********/
p = (n%2==0) n/2:n/2+___1___;
for (i=0; i
{
t=a[i];
/**********found**********/
a[i] = a[p+___2___];
/**********found**********/
___3___ = t;
}
}
main()
{int b[N]={1,2,3,4,5,6,7,8,9}, i;
printf("\nThe original data :\n");
for (i=0; i
fun(b, N);
printf("\nThe data after moving :\n");
for (i=0; i
}
解题答案:
/**********第一空**********/
p = (n%2==0) n/2:n/2+1;
/**********第二空*********/
a[i] = a[p+i];
/**********第三空**********/
a[p+i] = t;
******************************************
相关推荐: