PDA

View Full Version : زیر منو



ghaum
سه شنبه 26 فروردین 1382, 11:49 صبح
سلام

من کد مربوط به زیرمنو را می خواهم
کد مربوط به ساخت منو را دارم



متشکرم

rez6rez6
جمعه 27 دی 1387, 01:34 صبح
:تشویق:اینم برنامه #include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
typedef struct node *p_node;
typedef struct node{
char name[20];
long id;
int mark;
p_node link;
};
p_node start;

//********************** A D D ********************
void add()
{
p_node temp,x,y;
temp=new(node);
temp->link=NULL;
cout << "Enter ID";
cin >> temp->id;
cout << "Enter Name";
cin >> temp->name;
cout << "Enter mark";
cin >> temp->mark;
if (start != NULL)
{
x=start;
while(x->link)
x=x->link;
x->link=temp;
}
else
start=temp;
}// end of add
//**************** view ****************
void view()
{
p_node x;
x=start;
while (x)
{
cout << x->id<<"\t";
cout <<x->name<<"\t";
cout << x->mark<<"\t";
cout <<endl;
x=x->link;
}
getch();
}
//********************** d e l *******************
void del()
{
p_node s,y;
long n;
s=start;
cout<<"enter id for delete:";
cin>>n;
while(s)
{
if(n != s->id){
y=s;
s=s->link;
}
else
{
y->link=s->link;
delete(s);
break;
}
}// end while
}// end del
//******************** search ***************
void search (){
p_node s;
long n;
int t;
t=0;
cout<<"enter search:" ;
cin>>n;
s=start;
while(s){
if(n ==s->id)
{
cout <<s->id<<"\t";
cout <<s->name<<"\t";
cout <<s->mark<<"\t";
cout <<endl;
t=1;
}
s=s->link;
}//end while
if (t==0)
cout <<"Not Found !!!";
getch();
}//end search
//******************** EDIT *************
void edit(){
p_node k;
long b ;
cout<<"Enter a number for edit:";
cin>>b;
k=start;
while(k){
k=k->link;
if (b==k->id){
cout<<"enter id for edit:";
cin>>k->id;
cout<<"enter name for edit:";
cin>>k->name;
cout<<"enter mark for edit:";
cin>>k->mark;
cout<<k->id<<"\t";
cout<<k->name<<"\t";
cout<<k->mark<<"\t";
}
}//end while
getch();
}//end edit


//*************************************
void main()
{
int c,n;
start=NULL;
while(1)
{
clrscr();
cout<<"1.add:"<<endl;
cout<<"2.Edit:"<<endl;
cout<<"3.delete:"<<endl;
cout<<"4.view:"<<endl;
cout<<"5.search:"<<endl;
cout<<"6.exit:"<<endl;
cout<<"enter the number:";
cin>>c;
if (c=6)
exit(1);
if (c=1)
add();
if(c=4)
view();
if (c=3)
del();
if (c=5)
search();
if (c=2)
edit();

}//end of while 1
}//end of main