0

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

 
esfahaniran88
esfahaniran88
کاربر طلایی2
تاریخ عضویت : اردیبهشت 1388 
تعداد پست ها : 2290
محل سکونت : اصفهان

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



مشخصات دانشجویان با امکان ورود اطلاعات حذف اطلاعات و جستجو
کد:
#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);
}
}
}

کاش میدانستی که نباید حس کرد که نباید
دل بست در فضایی که بر از همهمه ی ادم هاست...من گرفتار ترین تنهایم!

 

 



 

جمعه 28 آبان 1389  9:35 PM
تشکرات از این پست
rozgol
aoghnoom
aoghnoom
کاربر برنزی
تاریخ عضویت : آبان 1389 
تعداد پست ها : 105
محل سکونت : فارس
دوشنبه 1 آذر 1389  12:56 PM
تشکرات از این پست
دسترسی سریع به انجمن ها