谁能帮我看看,为什么elemtype会没有的定义?
#define OK 1#define null 0
#define error 0
#define OVERFLOW 0
#define LIST_INTT_SIZE 10000
#define LISTINCREMENT 10
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#include<string.h>
struct student
{
char name[20];
long int number;
int age;
float score;
float Chinese;
float math;
float English;
};
typedef int status;
typedef student elemtype;
typedef struct
{
elemtype *elem;
int length;
int listsize;
}sqlist;
status initlist_sq(sqlist &L)
{
L.elem=(elemtype*)malloc(1000*sizeof(elemtype));
if(!L.elem)
exit(OVERFLOW);
L.length=0;
L.listsize=LIST_INTT_SIZE;
return OK;
}
void datain_sq(sqlist &L)
{
int i;
/*int n;
printf("请输入读入学生的个数:\n");
scanf("%d",&n);*/
for(i=0;i<3;i++)
{
scanf("%s%ld%d%f%f%f%f",L.elem[i].name,&L.elem[i].number,&L.elem[i].age,&L.elem[i].score,&L.elem[i].Chinese,&L.elem[i].math,&L.elem[i].English);
L.length++;
}
}
status dataout_sq(sqlist &L)
{
int i;
for(i=0;i<L.length;i++)
printf("%s\t%ld\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",L.elem[i].name, L.elem[i].number,L.elem[i].age,L.elem[i].score,L.elem[i].Chinese,L.elem[i].math,L.elem[i].English);
return OK;
}
status listinsert_sq(sqlist &L, int i,elemtype &e) //在顺序表第i个位置插入学生数据
{
elemtype *p,*q;
if(i<=0||i>L.length)
{
printf("插入位置错误\n");
return OK;
}
q=&(L.elem[i-1]);
for(p=&(L.elem[L.length-1]);p>=q;p--)
*(p+1)=*p;
*q=e;
++L.length;
return OK;
}
status listdelete_sq(sqlist &L,long int b,elemtype &e)//按学生学号删除学生数据
{
elemtype *p,*q;
int i,count=0;
for(i=0;i<=L.length-1;i++)
{
if(L.elem[i].number==b)
{
count++;
break;
}
}
if(count==1)
{
p=&(L.elem[i]);
e=*p;
q=L.elem+L.length-1;
for(p++;p<=q;p++)
*(p-1)=*p;
L.length--;
}
if(count==0)
printf("没有该生的信息\n");
return count;
}
void search_name(sqlist &L,char *stu)
{
int i;
int n=0;
for(i=0;i<=L.length;i++)
if(!strcmp(L.elem[i].name,stu))
{
n++;
if(n==1)
printf("姓名\t学号\t年龄\t总分\t语文\t数学\t英语\n");
printf("%s\t%ld\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",L.elem[i].name, L.elem[i].number,L.elem[i].age,L.elem[i].score,L.elem[i].Chinese,L.elem[i].math,L.elem[i].English);
}
if(n==0)
printf("没有找到相关数据\n");
}
void search_age(sqlist &L,int key)
{
int i;
for(i=0;i<L.length;i++)
{
int n=0;
if(L.elem[i].age==key)
{
n++;
if(n==1)
{
printf("姓名\t学号\t年龄\t总分\t语文\t数学\t英语\n");
printf("%s\t%ld\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",L.elem[i].name, L.elem[i].number,L.elem[i].age,L.elem[i].score,L.elem[i].Chinese,L.elem[i].math,L.elem[i].English);
}
if(n==0)
printf("没有找到相关数据\n");
}
}
}
void search_agerange(sqlist &L,int low,int up)
{
int i;
for(i=0;i<=L.length;i++)
{
int n=0;
if(L.elem[i].age<=up&&L.elem[i].age>=low)
{
n++;
if(n==1)
{
printf("姓名\t学号\t年龄\t总分\t语文\t数学\t英语\n");
printf("%s\t%ld\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",L.elem[i].name, L.elem[i].number,L.elem[i].age,L.elem[i].score,L.elem[i].Chinese,L.elem[i].math,L.elem[i].English);
}
if(n==0)
printf("没有找到相关数据\n");
}
}
}
void search_score(sqlist &L,float key)
{
int i;
for(i=0;i<=L.length;i++)
{
int n=0;
if(L.elem[i].score==key)
{
n++;
if(n==1)
{
printf("姓名\t学号\t年龄\t总分\t语文\t数学\t英语\n");
printf("%s\t%ld\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",L.elem[i].name, L.elem[i].number,L.elem[i].age,L.elem[i].score,L.elem[i].Chinese,L.elem[i].math,L.elem[i].English);
}
if(n==0)
printf("没有找到相关数据\n");
}
}
}
void search_scorerange(sqlist &L,float low,float up)
{
int i;
for(i=0;i<=L.length;i++)
{
int n=0;
if(L.elem[i].score<=up&&L.elem[i].score>=low)
{
if(n==1)
{
printf("姓名\t学号\t年龄\t总分\t语文\t数学\t英语\n");
printf("%s\t%ld\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",L.elem[i].name, L.elem[i].number,L.elem[i].age,L.elem[i].score,L.elem[i].Chinese,L.elem[i].math,L.elem[i].English);
}
if(n==0)
printf("没有找到相关数据\n");
}
}
}
void search_Chinese(sqlist &L,float key)
{
int i;
for(i=0;i<=L.length;i++)
{
int n=0;
if(L.elem[i].Chinese==key)
{
n++;
if(n==1)
{
printf("姓名\t学号\t年龄\t总分\t语文\t数学\t英语\n");
printf("%s\t%ld\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",L.elem[i].name, L.elem[i].number,L.elem[i].age,L.elem[i].score,L.elem[i].Chinese,L.elem[i].math,L.elem[i].English);
}
if(n==0)
printf("没有找到相关数据\n");
}
}
}
void search_Chineserange(sqlist &L,float low,float up)
{
int i;
for(i=0;i<=L.length;i++)
{
int n=0;
if(L.elem[i].Chinese<=up&&L.elem[i].Chinese>=low)
{
n++;
if(n==1)
{
printf("姓名\t学号\t年龄\t总分\t语文\t数学\t英语\n");
printf("%s\t%ld\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",L.elem[i].name, L.elem[i].number,L.elem[i].age,L.elem[i].score,L.elem[i].Chinese,L.elem[i].math,L.elem[i].English);
}
if(n==0)
printf("没有找到相关数据\n");
}
}
}
void search_math(sqlist &L,float key)
{
int i;
for(i=0;i<=L.length;i++)
{
int n=0;
if(L.elem[i].math==key)
{
n++;
if(n==1)
{
printf("姓名\t学号\t年龄\t总分\t语文\t数学\t英语\n");
printf("%s\t%ld\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",L.elem[i].name, L.elem[i].number,L.elem[i].age,L.elem[i].score,L.elem[i].Chinese,L.elem[i].math,L.elem[i].English);
}
if(n==0)
printf("没有找到相关数据\n");
}
}
}
void search_mathrange(sqlist &L,float low,float up)
{
int i;
for(i=0;i<=L.length;i++)
{
int n=0;
if(L.elem[i].math<=up&&L.elem[i].math>=low)
{
n++;
if(n==1)
{
printf("姓名\t学号\t年龄\t总分\t语文\t数学\t英语\n");
printf("%s\t%ld\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",L.elem[i].name, L.elem[i].number,L.elem[i].age,L.elem[i].score,L.elem[i].Chinese,L.elem[i].math,L.elem[i].English);
}
if(n==0)
printf("没有找到相关数据\n");
}
}
}
void search_English(sqlist &L,float key)
{
int i;
for(i=0;i<=L.length;i++)
{
int n=0;
if(L.elem[i].English==key)
{
n++;
if(n==1)
{
printf("姓名\t学号\t年龄\t总分\t语文\t数学\t英语\n");
printf("%s\t%ld\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",L.elem[i].name, L.elem[i].number,L.elem[i].age,L.elem[i].score,L.elem[i].Chinese,L.elem[i].math,L.elem[i].English);
}
if(n==0)
printf("没有找到相关数据\n");
}
}
}
void search_Englishrange(sqlist &L,float low,float up)
{
int i;
for(i=0;i<=L.length;i++)
{
int n=0;
if(L.elem[i].English<=up&&L.elem[i].English>=low)
{
n++;
if(n==1)
{
printf("姓名\t学号\t年龄\t总分\t语文\t数学\t英语\n");
printf("%s\t%ld\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",L.elem[i].name, L.elem[i].number,L.elem[i].age,L.elem[i].score,L.elem[i].Chinese,L.elem[i].math,L.elem[i].English);
}
if(n==0)
printf("没有找到相关数据\n");
}
}
}
void search_number(sqlist &L,long int key)
{
int i;
for(i=0;i<=L.length;i++)
{
int n=0;
if(L.elem[i].number==key)
{
n++;
if(n==1)
{
printf("姓名\t学号\t年龄\t总分\t语文\t数学\t英语\n");
printf("%s\t%ld\t%d\t%.2f\t%.2f\t%.2f\t%.2f\n",L.elem[i].name, L.elem[i].number,L.elem[i].age,L.elem[i].score,L.elem[i].Chinese,L.elem[i].math,L.elem[i].English);
}
if(n==0)
printf("没有找到相关数据\n");
}
}
}
status insertsort_number_sq(sqlist &L) //学生学号用插入方法排序
{
elemtype temp;
int i,j;
for(i=1;i<L.length;i++)
if(L.elem[i].number<L.elem[i-1].number)
{
temp=L.elem[i];
L.elem[i]=L.elem[i-1];
for(j=i-1;j>=0&&temp.number<L.elem[j].number;j--)
L.elem[j+1]=L.elem[j];
L.elem[j+1]=temp;
}
return OK;
}
status insertsort_age_sq(sqlist &L) //学生年龄用插入方法排序
{
elemtype temp;
int i,j;
for(i=1;i<L.length;i++)
if(L.elem[i].age<L.elem[i-1].age)
{
temp=L.elem[i];
L.elem[i]=L.elem[i-1];
for(j=i-1;j>=0&&temp.age<L.elem[j].age;j--)
L.elem[j+1]=L.elem[j];
L.elem[j+1]=temp;
}
return OK;
}
status partition_math_sq(sqlist &L,int low,int high) //交换顺序表L中子表L.r[low...high]的记录,使枢轴记录到位,并返回其所在位置,此时在它之前(后)的记录均不大(小)于它
{
float pivokey;
elemtype temp;
pivokey=L.elem[low].math; //用子表的第一个记录作枢轴记录
while(low<high)
{
while(low<high&&L.elem[high].math>=pivokey)
high--;
temp=L.elem[low];
L.elem[low]=L.elem[high];
L.elem[high]=temp;
while(low<high&&L.elem[low].math<=pivokey)
low++;
temp=L.elem[low];
L.elem[low]=L.elem[high];
L.elem[high]=temp;
}
return low;
}
status Qsort_math_sq(sqlist &L,int low,int high)
{
int pivotloc;
if(low<high)
{
pivotloc=partition_math_sq(L,low,high);
Qsort_math_sq(L,low,pivotloc-1);
Qsort_math_sq(L,pivotloc+1,high);
}
return OK;
}
status Quicksort_math_sq(sqlist &L)
{
Qsort_math_sq(L,0,L.length-1);
return OK;
}
status partition_English_sq(sqlist &L,int low,int high)
{
float pivokey;
elemtype temp;
pivokey=L.elem[low].English;
while(low<high)
{
while(low<high&&L.elem[high].English>=pivokey)
high--;
temp=L.elem[low];
L.elem[low]=L.elem[high];
L.elem[high]=temp;
while(low<high&&L.elem[low].English<=pivokey)
low++;
temp=L.elem[low];
L.elem[low]=L.elem[high];
L.elem[high]=temp;
}
return low;
}
status Qsort_English_sq(sqlist &L,int low,int high)
{
int pivotloc;
if(low<high)
{
pivotloc=partition_English_sq(L,low,high);
Qsort_English_sq(L,low,pivotloc-1);
Qsort_English_sq(L,pivotloc+1,high);
}
return OK;
}
status Quicksort_English_sq(sqlist &L)
{
Qsort_English_sq(L,0,L.length-1);
return OK;
}
status partition_Chinese_sq(sqlist &L,int low,int high)
{
float pivokey;
elemtype temp;
pivokey=L.elem[low].Chinese;
while(low<high)
{
while(low<high&&L.elem[high].Chinese>=pivokey)
high--;
temp=L.elem[low];
L.elem[low]=L.elem[high];
L.elem[high]=temp;
while(low<high&&L.elem[low].Chinese<=pivokey)
low++;
temp=L.elem[low];
L.elem[low]=L.elem[high];
L.elem[high]=temp;
}
return low;
}
status Qsort_Chinese_sq(sqlist &L,int low,int high)
{
int pivotloc;
if(low<high)
{
pivotloc=partition_Chinese_sq(L,low,high);
Qsort_Chinese_sq(L,low,pivotloc-1);
Qsort_Chinese_sq(L,pivotloc+1,high);
}
return OK;
}
status Quicksort_Chinese_sq(sqlist &L)
{
Qsort_Chinese_sq(L,0,L.length-1);
return OK;
}
status partition_score_sq(sqlist &L,int low,int high)
{
float pivokey;
elemtype temp;
pivokey=L.elem[low].score;
while(low<high)
{
while(low<high&&L.elem[high].score>=pivokey)
high--;
temp=L.elem[low];
L.elem[low]=L.elem[high];
L.elem[high]=temp;
while(low<high&&L.elem[low].score<=pivokey)
low++;
temp=L.elem[low];
L.elem[low]=L.elem[high];
L.elem[high]=temp;
}
return low;
}
status Qsort_score_sq(sqlist &L,int low,int high)
{
int pivotloc;
if(low<high)
{
pivotloc=partition_score_sq(L,low,high);
Qsort_score_sq(L,low,pivotloc-1);
Qsort_score_sq(L,pivotloc+1,high);
}
return OK;
}
status Quicksort_score_sq(sqlist &L)
{
Qsort_score_sq(L,0,L.length-1);
return OK;
}
float lowscore_sq(sqlist &L)
{
int i;
float low;
low=L.elem[0].score;
for(i=0;i<L.length;i++)
{
if(low>L.elem[i].score)
low=L.elem[i].score;
}
return low;
}
float highscore_sq(sqlist &L)
{
int i;
float high;
high=L.elem[0].score;
for(i=0;i<L.length;i++)
{
if(high<L.elem[i].score)
high=L.elem[i].score;
}
return high;
}
float lowChinese_sq(sqlist &L)
{
int i;
float low;
low=L.elem[0].Chinese;
for(i=0;i<L.length;i++)
{
if(low>L.elem[i].Chinese)
low=L.elem[i].Chinese;
}
return low;
}
float highChinese_sq(sqlist &L)
{
int i;
float high;
high=L.elem[0].Chinese;
for(i=0;i<L.length;i++)
{
if(high<L.elem[i].Chinese)
high=L.elem[i].Chinese;
}
return high;
}
float lowmath_sq(sqlist &L)
{
int i;
float low;
low=L.elem[0].math;
for(i=0;i<L.length;i++)
{
if(low>L.elem[i].math)
low=L.elem[i].math;
}
return low;
}
float highmath_sq(sqlist &L)
{
int i;
float high;
high=L.elem[0].math;
for(i=0;i<L.length;i++)
{
if(high<L.elem[i].math)
high=L.elem[i].math;
}
return high;
}
float lowEnglish_sq(sqlist &L)
{
int i;
float low;
low=L.elem[0].English;
for(i=0;i<L.length;i++)
{
if(low>L.elem[i].English)
low=L.elem[i].English;
}
return low;
}
float highEnglish_sq(sqlist &L)
{
int i;
float high;
high=L.elem[0].English;
for(i=0;i<L.length;i++)
{
if(high<L.elem[i].English)
high=L.elem[i].English;
}
return high;
}
int lowage_sq(sqlist &L)
{
int i;
int low;
low=L.elem[0].age;
for(i=0;i<L.length;i++)
{
if(low>L.elem[i].age)
low=L.elem[i].age;
}
return low;
}
int highage_sq(sqlist &L)
{
int i;
int high;
high=L.elem[0].age;
for(i=0;i<L.length;i++)
{
if(high<L.elem[i].age)
high=L.elem[i].age;
}
return high;
}