C++プログラム設計——学生通信録管理システム

3684 ワード

/*       */
#include 
#include 
#include 
#include 

using namespace std;
struct student{
char name[20];
char address[20];
char phonenum[20];
student *next;
};
//         


void mainscreen(student *p);
void title();
void Login(student *head);


void UserReg(student *head)
{
system("cls");
FILE *fp;                                  //      
char Linedata[50]={0},User[20],Pass[20];  //                   
fp = fopen("data.dat","at");              //  data.txt      
cout<>c;
if(c=='1')
{Login(head);}
else if(c=='2')
{UserReg(head);}
 }
}






void save(student *head)
{
FILE *fp;
student *point;
point=head;
    if((fp=fopen("F:\\lin.txt","wb+"))==NULL)
    {
        cout<next;
    }   
    fclose(fp);
}


void read(student *head)         //        
{
    FILE *p=fopen("F:\\lin.txt","rb");
    fread(head,sizeof(struct student),1,p);
    /*while(head)
{
cout<name);
cout<address);
cout<phonenum);
head=head->next;
}
*/
}




void assert_student(student *head)
{ 
system("cls");
title();
static student *p,*q;
if(head==NULL)
{ 
head=q=(struct student *)malloc(sizeof(student));
p=(struct student *)malloc(sizeof(student));
head->next=p;
cout<>p->name;
cout<>p->address;
cout<>p->phonenum;
q->next=p;
q=p;
q->next=NULL;
system("cls");
title();
}
else if(head!=NULL)
{ 
p=(struct student *)malloc(sizeof(student));
cout<>p->name;
cout<>p->address;
cout<>p->phonenum;
q->next=p;
q=p;
q->next=NULL;
system("cls");
title();
}
mainscreen(head);
}






void delete_student(student *head)
{ 
int flag=1;
system("cls");
char de_stu[20];
cout<>de_stu;
student *q,*front;
front=(struct student *)malloc(sizeof(student));
front=head; 
q=head->next;
while(q!=NULL)
{ 
if(strcmp(q->name,de_stu)==0)
{ 
cout<next;
front->next=q->next;
cout<next;
}
if(flag==1)
cout<>name_stu;
q=head->next;
while(q!=NULL)
{ 
if(strcmp(q->name,name_stu)==0)
{ 
cout<>q->name;
cout<>q->address;
cout<>q->phonenum;
cout<next;
}
if(flag==1)
cout<>location;
student *q;
q=head->next;
while(q!=NULL)
{
if(strcmp(q->address,location)==0)
{ 
cout<name<address<phonenum<next;
}
if(flag==1)
cout<>name_stu;
student *q;
q=head->next;
while(q!=NULL)
{
if(strcmp(q->name,name_stu)==0)
{ 
cout<name<address<phonenum<next;
}
if(flag==1)
cout<next;
while(q!=NULL)
{
cout<name<address<phonenum<next;
}
mainscreen(head);
}


void mainscreen(student *head)
{
int choice;
char a=14;
cout<>choice;
switch(choice)
{
case 1:assert_student(head);break;
case 2:search_student(head);break;
case 3:delete_student(head);break;
case 4:change_student(head);break;
case 5:  system("cls");save(head);exit(0);
case 6:show_student(head);break;
case 7:loca_student(head);break;
}
}
void title()
{
char a=3;
for(int i=0;i<90;i++)
cout<>selectNum;        //  された    の  
switch(selectNum)/  した   に って  を び す
{
case 1:UserReg(head);          //    の び し
break;
case 2:Login(head);           //ログイン  の び し
break;
case 3:system("cls");exit(0); //    の び し
break;
}
return 0;
}