return ;
}
Node q=p;
while(!feof(a1))
{
p->Num++;
Node NEW =new struct L;
fscanf(a1,"%s%lld%f%f",NEW->Name,&NEW->Num,&NEW->English,&NEW->C_language);
q->Next=NEW;
NEW->Next=NULL;
q=q->Next;
}
p->Num--;
printf("\t操作成功!\n");
fclose(a1);
getch();
return ;
}
else if(ch=='n'||ch=='N')
{
printf("\t操作被取消!\n");
getch();
return ;
}
else
{
printf("\t输入有误!\n");
getch();
return ;
}
}
void Export(Node p)
{
printf("\t警告:此操作将覆盖源文件中的数据!!\n");
char ch;
printf("\n");
printf("\t是否替换!(y/n)\n");
fflush(stdin);
printf("\t");
scanf("%c",&ch);
if(ch=='y'||ch=='Y')
{
FILE * a1;
char lujing[100];
printf("\t输入要导出文件的路径!\n");
fflush(stdin);
printf("\t");
gets(lujing);
a1=fopen(lujing,"wb");
if(a1==NULL)
{
printf("\t打开文件失败,导出数据失败!\n");
return ;
}
int len=p->Num;
for(int i=0;i
p=p->Next;
fprintf(a1,"%s %lld %.2f %.2f\n",p->Name,p->Num,p->English,p->C_language);
}
printf("\t操作成功!\n");
fclose(a1);
getch();
return ;
}
else if(ch=='n'||ch=='N')
{
printf("\t操作被取消!\n");
getch();
return ;
}
else
{
printf("\t输入有误!\n");
getch();
return ;
}
}
#include
#include
#include
#include
typedef struct L
{
char Name[30];
long long Num;
float English;
float C_language;
struct L *Next;
}*Node;
void Menu(); //功能菜单
void Search(Node p); //查找
void Name_Search(Node p); //按姓名查找
void Num_Search(Node p); //按学号查找
void Initialization(Node p); //初始化表
void Add(Node p); // 添加
void Insert(Node p); //插入
void Delet(Node p); //删除
void Show(Node p); //显示
void Sort(Node p); //排序
void C_Sort(Node p); //c成绩排序
void En_Sort(Node p); //英语成绩排序
void Num_Sort(Node p); // 学号排序
void All_Sort(Node p); //总成绩排序
void Most(Node p); //最大值
void DelName(Node p); //按姓名删除
void DelNum(Node p); //按学号删除
void Modify(Node p); //修改
void Num_Modify(Node p); //按学号修改
void Name_Modify(Node p); //按姓名修改
void Menu1(); //菜单
void Explanation(); //说明
void Import(Node p); //从文件导入数据
void Export(Node p); //将数据导入到外部文件中
int main()
{
Node p=new struct L;
system("color 1a");
Initialization(p);
Menu();
printf("\t选择:\n");
printf("\t");
int m;
while(true)
{
scanf("%d",&m);
if(m==11)
{
Explanation();
getch();
system("cls");
break;
}
else
{
printf("\t请先看说明!\n");
printf("\t");
}
}
Menu1();
printf("\t选择:\n");
printf("\t");
int n;
while(scanf("%d",&n)!=EOF)
{
switch(n)
{
case 1:
Add(p);fflush(stdin);break;
case 2:
Show(p);fflush(stdin);break;
case 3:
Insert(p);fflush(stdin);break;
case 4:
Sort(p);fflush(stdin);break;
case 5: