|
|
|
@ -0,0 +1,164 @@
|
|
|
|
|
//333333333333
|
|
|
|
|
void case3() {//综合信息排序浏览
|
|
|
|
|
int v;
|
|
|
|
|
LIGHT();
|
|
|
|
|
printf("提示:1,按照学号排序;2,按照姓名排序.请键入:");
|
|
|
|
|
GREEN();
|
|
|
|
|
scanf("%d",&v);
|
|
|
|
|
init() ;
|
|
|
|
|
if(v==1) {
|
|
|
|
|
stuid_sort(0,i_entry);
|
|
|
|
|
i_printf();
|
|
|
|
|
}
|
|
|
|
|
if(v==2) {
|
|
|
|
|
name_sort(0,i_entry);
|
|
|
|
|
i_printf();
|
|
|
|
|
}
|
|
|
|
|
file_save();
|
|
|
|
|
}
|
|
|
|
|
void stuid_sort(int I,int L)//归并排序,学号由低到高
|
|
|
|
|
{ int i,mid;
|
|
|
|
|
system("cls");
|
|
|
|
|
if(I>=L)
|
|
|
|
|
return ;
|
|
|
|
|
mid=(I+L)/2;
|
|
|
|
|
stuid_sort(I,mid);
|
|
|
|
|
stuid_sort(mid+1,L);
|
|
|
|
|
int I1=I,r1=mid,r2=L,I2=mid+1;
|
|
|
|
|
int t=0;
|
|
|
|
|
while(I1<=r1&&I2<=r2)
|
|
|
|
|
{
|
|
|
|
|
if(DATA[I1].stuid<DATA[I2].stuid)
|
|
|
|
|
temp[t++]=DATA[I1++];
|
|
|
|
|
else
|
|
|
|
|
temp[t++]=DATA[I2++];
|
|
|
|
|
}
|
|
|
|
|
while(I1<=r1)
|
|
|
|
|
temp[t++]=DATA[I1++];
|
|
|
|
|
while(I2<=r2)
|
|
|
|
|
temp[t++]=DATA[I2++];
|
|
|
|
|
for(i=t-1;i>=0;i--)
|
|
|
|
|
DATA[i+I]=temp[i];
|
|
|
|
|
}
|
|
|
|
|
void name_sort(int I,int L)//归并排序,姓名由低到高
|
|
|
|
|
{ int i,mid;
|
|
|
|
|
system("cls");
|
|
|
|
|
if(I>=L)
|
|
|
|
|
return ;
|
|
|
|
|
mid=(I+L)/2;
|
|
|
|
|
stuid_sort(I,mid);
|
|
|
|
|
stuid_sort(mid+1,L);
|
|
|
|
|
int I1=I,r1=mid,r2=L,I2=mid+1;
|
|
|
|
|
int t=0;
|
|
|
|
|
while(I1<=r1&&I2<=r2)
|
|
|
|
|
{
|
|
|
|
|
if(DATA[I1].stuid<DATA[I2].stuid)
|
|
|
|
|
temp[t++]=DATA[I1++];
|
|
|
|
|
else
|
|
|
|
|
temp[t++]=DATA[I2++];
|
|
|
|
|
}
|
|
|
|
|
while(I1<=r1)
|
|
|
|
|
temp[t++]=DATA[I1++];
|
|
|
|
|
while(I2<=r2)
|
|
|
|
|
temp[t++]=DATA[I2++];
|
|
|
|
|
for(i=t-1;i>=0;i--)
|
|
|
|
|
DATA[i+I]=temp[i];
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
void stuid_sort() {//学号排序 冒泡排序算法
|
|
|
|
|
int r,t;
|
|
|
|
|
system("cls");
|
|
|
|
|
puts("***************>>>>>>当前模式以学号排序后浏览状态<<<<<<*************");
|
|
|
|
|
//struct student temp;
|
|
|
|
|
for(r=1; r<i_entry; r++) {
|
|
|
|
|
for(t=0; t<i_entry-r; t++) {
|
|
|
|
|
if(strcmp(DATA[t+1].stuid, DATA[t].stuid)<0) {//学号由低到高
|
|
|
|
|
temp=DATA[t+1];
|
|
|
|
|
DATA[t+1]=DATA[t];
|
|
|
|
|
DATA[t]=temp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
/*void name_sort() {//姓名排序 冒泡排序算法
|
|
|
|
|
int j,k;
|
|
|
|
|
system("cls");
|
|
|
|
|
puts("***************>>>>>>当前模式以姓名排序后浏览状态<<<<<<*************");
|
|
|
|
|
//struct student temp;
|
|
|
|
|
for(j=1; j<i_entry; j++) {
|
|
|
|
|
for(k=0; k<i_entry-j; k++) {
|
|
|
|
|
if(strcmp(DATA[k+1].name,DATA[k].name)<0) {
|
|
|
|
|
are=DATA[k+1];
|
|
|
|
|
DATA[k+1]=DATA[k];
|
|
|
|
|
DATA[k]=are;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
//55555555555
|
|
|
|
|
void case5() {//学生综合信息修改
|
|
|
|
|
int flag,i,t;
|
|
|
|
|
system("cls");
|
|
|
|
|
puts("***************>>>>>>当前模式为学生信息修改状态<<<<<<*************");
|
|
|
|
|
LIGHT();
|
|
|
|
|
printf("选定检索方式:1.学号检索\t2.姓名检索. 请键入:");
|
|
|
|
|
GREEN();
|
|
|
|
|
flag=0;
|
|
|
|
|
scanf("%d",&t);
|
|
|
|
|
if(t==2) {
|
|
|
|
|
LIGHT();
|
|
|
|
|
init();
|
|
|
|
|
printf("请输入需要修改的学生姓名:");
|
|
|
|
|
scanf("%s",&DATA[i_entry].name);
|
|
|
|
|
GREEN();
|
|
|
|
|
for(i=0; i<i_entry; i++) //判断输入数据的正误
|
|
|
|
|
if(strcmp(DATA[i].name,DATA[i_entry].name)==0) {
|
|
|
|
|
flag=1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if(flag==1) {
|
|
|
|
|
Change(i);
|
|
|
|
|
}
|
|
|
|
|
if(flag==0)
|
|
|
|
|
puts("该姓名不存在,请检查输入是否有误!");
|
|
|
|
|
}
|
|
|
|
|
if(t==1) {
|
|
|
|
|
LIGHT();
|
|
|
|
|
init();
|
|
|
|
|
printf("请输入需要修改的学生学号:");
|
|
|
|
|
scanf("%s",&DATA[i_entry].stuid);
|
|
|
|
|
GREEN();
|
|
|
|
|
for(i=0; i<i_entry; i++) //判断输入数据的正误
|
|
|
|
|
if(strcmp(DATA[i].stuid,DATA[i_entry].stuid)==0) {
|
|
|
|
|
flag=1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if(flag==1) {
|
|
|
|
|
Change(i);
|
|
|
|
|
}
|
|
|
|
|
if(flag==0)
|
|
|
|
|
puts("该学号不存在,请检查输入是否有误!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Change(int x) {//学生信息的更改提示内容
|
|
|
|
|
printf("请输入修改后的学生学号:");
|
|
|
|
|
scanf("%s",DATA[x].stuid);
|
|
|
|
|
printf("请输入修改后的学生姓名:");
|
|
|
|
|
scanf("%s",DATA[x].name);
|
|
|
|
|
printf("请输入修改后的学生年龄:");
|
|
|
|
|
scanf("%s",DATA[x].age);
|
|
|
|
|
printf("请输入修改后的学生性别:");
|
|
|
|
|
scanf("%s",DATA[x].gender);
|
|
|
|
|
printf("请输入修改后的学生出生年月日(以/隔开):");
|
|
|
|
|
scanf("%s",DATA[x].birth);
|
|
|
|
|
printf("请输入修改后的学生联系地址:");
|
|
|
|
|
scanf("%s",DATA[x].add);
|
|
|
|
|
printf("请输入修改后的学生联系电话:");
|
|
|
|
|
scanf("%s",DATA[x].tle);
|
|
|
|
|
printf("请输入修改后的学生联系邮箱:");
|
|
|
|
|
scanf("%s",DATA[x].email);
|
|
|
|
|
puts("数据修改完成!");
|
|
|
|
|
file_save();
|
|
|
|
|
}
|
|
|
|
|
|