gets(thisN->class_);
head = thisN;
return;
}
//删除数据*********************************
void delete_information()
{
int choose;
int StuNum;
char name[30],class_[30];
node *p1,*p2;
system("cls");//清屏
//空的
if ( head == NULL)
{
printf("\n空的删什么啊?\n");
return ;
}
//不是空的
//选择删除方式
printf("\nplese choose the way you want to delete:\nchoose 1 to delete by student number.\nchoose 2 to delete by student name\nchoose 3 to delete a class\n");
scanf("%d",&choose);
getchar();
//清屏
system("cls");
switch(choose)
{
case 1:
{
printf("\nplese input the number of the student:");
scanf("%d",&StuNum);
p1 = head;
while( StuNum != p1->number && p1->next != NULL)
{
p2 = p1; //临时保留
p1 = p1->next;
}
//找到出来
if( StuNum == p1->number)
{
if( p1 == head)
{
head = p1->next;
}
else
{
p2->next = p1->next;
}
free(p1);
printf("\n删了删了\n");
}
else
printf("\n找不到啊,大哥\n");
}break;
case 2:
{
printf("please input the name of the student:");
gets(name);
p1 = head;
while(strcmp(name,p1->name) != 0 && p1->next != NULL)
{
p2 = p1;
p1 = p1->next;
}
if(strcmp(name,p1->name) == 0)
{
if(p1 == head)
{
head = p1->next;
}
else
{
p2->next = p1->next;
}
free(p1);
printf("\n删掉了噢\n");
}
else
{
printf("\n找不到o\n");
}
}
break;
case 3:
{
printf("\nplease input the class you want to delete:");
gets(class_);
int flag;
do
{
flag = 0;
p1 = head;
while(strcmp(class_,p1->class_) != 0 && p1->next != NULL)
{
p2 = p1;
p1 = p1->next;
}
if(p1->next == NULL){printf("\n此班已经消除\n");flag = 1;}
if(strcmp(class_,p1->class_) == 0)
{
if(p1 == head)
{
head = p1->next;
}
else
{
p2->next = p1->next;
}
free(p1);
}
}while(flag == 0);
}
break;
}
return;
}
//查找数据***********************************************
void search_information()
{
extern node *head;
node *p1;
int Stunum;
system("cls");//清屏
//空
if( head == NULL)
{
printf("\n什么都没有查什么\n");
return;
}
//非空
printf("\n请输入你要查找的学号:");
scanf("%d",&Stunum);
getchar();
p1 = head;
while(Stunum != p1->number && p1->next != NULL)
{
p1 = p1->next;
}
//找到跳出循环
if( Stunum == p1->number)
{
printf("\nname:%s",p1->name);
printf("\nage:%d",p1->age); //输出
printf("\nclass:%s",p1->class_);
printf("\nnumber:%d",p1->number);
printf("\nsex:%c",p1->sex);
printf("\nscore:%f",p1->score);
}
else
{
printf("\n找不到啊\n");
return;
}
}
//修改数据**************************************************************
void modify_information()
{
extern node *head;
int studnum;
node *p1;
system("cls");//清屏
//empty
if( head == NULL)
{
printf("\n东西都没有你怎么改?\n");
return;
}
//no empty
p1 = head ;
printf("\n请输入你想查找的学号");
scanf("%d",&studnum);
getchar();
while( studnum != p1->number && p1->next != NULL)
{
p1 = p1->next;
}
//找到了出来
if( studnum == p1->number)
{
printf("\nenter name:");
gets(p1->name);
getchar();
printf("\nenter number:");
scanf("%d",&p1->number);
printf("\nenter age:");
scanf("%d",&p1->age);
printf("\nenter sex:");
scanf("%c",&p1->sex);
printf("\nenter score:");
scanf("%lf",&p1->score);
printf("\nenter clase:");
gets(p1->class_);
}
else
{
printf("\n真找不到。\n");
return;
}
}
//管理员权限
void manage()
{
printf("\n敬请期待。。。\n");
}
//主函数
int main()
{
extern node *head = NULL;
do
{
Menu();
choice();
printf("press anykey to continue\n");
getch();
getchar();
system("cls");
}while(1);
return 0;
}
坑爹版