给你举个例子吧!
#include
#define N 5
main()
{
int num[N+1]={1002,1003,1006,1008,1010}; /*必须多开辟一个存储单元*/
int i=0,j=0,new=0;
printf("Original number:\n");
for(i=0;i
printf("\n");
printf("Input a student number:"); /*输入要插入的学号*/
scanf("%d",&new);
for(i=0;i
for(j=N;j>i;j--) /*将数据向后移动*/
num[j]=num[j-1];
num[i]=new; /*插入数据*/
printf("Final numbers:\n");
for(i=0;i
printf("\n");
}