سورس دريافت مشخصات دانشجویان با امکان ورود اطلاعات حذف اطلاعات و جستجو


#include <iostream.h>
#include <conio.h>
#include <stdlib.h>


struct student{
char name[20];
char family[25];
int id;
student *next;
};
student *first,*last;
//////////////////////////
void input(){
student *temp=new student;
cout<<"plese enter the id : "<<endl;
cin>>temp->id;
cout<<"plese enter the name : "<<endl;
cin>>temp->name;
cout<<"plese enter the family : "<<endl;
cin>>temp->family;
if (first==NULL){
first=last=temp;
}
else {
temp->next=last;
last=temp;
}
}
/////////////////////////////////
void output(){
student *temp=new student;
temp=first;
while(temp!=NULL){
cout<<temp->id<<endl;
cout<<temp->name<<endl;
cout<<temp->family<<endl;
cout<<"*************************************";
temp=temp->next;
}
cout<<"end of record"<<endl;
}
/////////////////////////////////////
void search(int id){
student *temp=new student;
int find;
temp=first;
while(temp!=NULL){
if (id==temp->id){
cout<<temp->id<<endl;
cout<<temp->name<<endl;
cout<<temp->family<<endl;
find=1;
break;
}
else{
find=0;
temp=temp->next;
}
}
if (find==0){ cout<<"not find record"<<endl;}
}
////////////////////////////////////
void main(){
int stat;
for (;;){
system("cls");
cout<<"***************************************"<<endl;
cout<<"num 1 for input data " <<endl;
cout<<"num 2 for list data " <<endl;
cout<<"num 3 for search data " <<endl;
cout<<"num 4 for exit" <<endl;
cout<<"***************************************"<<endl ;
cin>>stat;
system("cls");
switch(stat){
case 1:
input();
break;
case 2:
output();
break;
case 3:
int key;
cout<<"plese enter id for search : " ;
cin>>key;
search(key);
break;
case 4:
exit(0);
}
}
}