دریافت
عنوان: آموزش کیوت
حجم: 4.03 مگابایت
voidadd(intx){if(first==NULL){node *temp=newnode;first=temp;first->data=x;cout<<"\nEnter Name : ";cin>>first->name;first->next=NULL;last=first;}else{node *temp=newnode;last->next=temp;last=temp;last->data=x;cout<<"\nEnter Name : ";cin>>last->name;last->next=NULL;}}voiddel(inty){if(y==first->data){node *temp;temp=first->next;deletefirst;first=temp;}elseif(y==last->data){node *temp,*temp1;temp=temp1=first;while(1){temp1=temp;temp=temp->next;if(temp==last){deletelast;last=temp1;last->next=NULL;break;}}}else{node *temp,*temp1;temp=temp1=first;while(1){temp1=temp;temp=temp->next;if(temp->data==y){temp1->next=temp->next;deletetemp;break;}}}}voidshow(){node *n = first;while( n ) {cout << n->data <<" "<<n->name<<"\n";n = n->next;}cout <<'\n';}voidformat(){node *n = first;node *e = first;while( n ) {e=n;n = n->next;deletee;}}voidsearchlist(intl){node *n = first;while( 1 ) {if(n->data==l){cout << n->data <<" "<<n->name<<"\n";break;}else{n = n->next;}}}
#include "stdafx.h"#include <iostream>#include <conio.h>usingnamespacestd;structnode{intdata;charname [30];charfamily[30];charnumber[30];node *next;};node *first;node *last;voidadd(int);voiddel(int);voidshow();voidformat();voidsearchlist(int);int_tmain(intargc, _TCHAR* argv[]){intans;inta;intd;while(1){cout<<"\n 1-add 2-del 3-show 4-format list 5-searchlist (Enter |6| key to Exit) : ";cin>>ans;if(ans==1){cout<<"\nEnter Number for add : ";cin>>a;add(a);}elseif(ans==2){cout<<"\nEnter Number for del : ";cin>>d;del(d);}elseif(ans==3){show();}elseif(ans==4){format();cout<<"END Life this linked list ";_getch();break;}elseif(ans==5){intl;cout<<"\nEnter Number for search : ";cin>>l;searchlist(l);}else{break;}}_getch();return0;}