加2个功能哦!!!
#include <stdio.h >
#include <stdlib.h >
#include <string.h >
#define maxlen 100
typedef struct student
{ char name[10],no[10];
int math,eng,comp;
}elemtype;
int insert(int a[],int *n,int i,int x)
{int j;
if(i<0||i>*n)
{
printf( "\n the position is invalid ");
return 0; }
else if(*n==maxlen-1)
{printf( "\n the list is full ");
return 0; }
else
{for(j=*n-1;j >=i;j--)a[j+1]=a[j];
a[i]=x;
(*n)++;
return 1;
}
}
int del(elemtype a[],int *n,int i)
{int j;
if(i<0||i>*n-1)
{printf( "\n the position is invalid ");
return 0; }
else
{
for(j=i+1;j <=*n-1;j++)a[j-1]=a[j];
(*n)--;
return 1;
}
}
main()
{ int i,choice,a[maxlen],position,date,*len;*len=10;
printf( "\n 1..................input the table ");
printf( "\n 2..................insert date ");
printf( "\n 3..................delete date ");
printf( "\n 4..................display the table ");
printf( "\n 0..................exit the program ");
do
{
printf( "\n please input your choice: ");
scanf( "%d ",&choice);
switch(choice)
{case 1:
printf( "\n please input the date onebye: ");
for(i=0;i <*len;i++)
scanf( "%d ",&a[i]);
break;
case 2:
printf( "\n please input the insert position: ");
scanf( "%d ",&position);
printf( "\n please input the insert date: ");
scanf( "%d ",&date);
insert (a,len,position,date);
break;
case 3:
printf( "\n please input the delete position: ");
scanf( "%d ",&position);
del(a,len,position);
break;
case 4:
printf( "display the table : ");
for(i=0;i,*len;i++)
printf( "\n %3d ",a[i]);
break;
case 0:
exit(0);
}
}while(choice!=0);
}
给上面的程序加2个功能:一个是查找,一个是排序。帮帮忙哦
问题点数:10、回复次数:1Top
1 楼liujingfu123(Oh_My_GoD)回复于 2004-12-02 08:23:48 得分 10
你得先告诉我查找的条件, 以及排序的关键字顺序啊Top




