struct daneshjoo{
int ID;
char Name[20];
char Family[30];
char Otagh[15];
int ShOtagh;
char D_N[5];
int sokonat;
}STD[up];
void menu(){
clrscr();
int S;
cout<<“Plaese Choice :\n”;
while(1){
cout<<“1- Enter.\n”;
cout<<“2- Edit Student.\n”;
cout<<“3- Delete Student.\n”;
cout<<“4- show.\n”;
cout<<“5- Search.\n”;
cout<<“6- END.\n”;
cin>>S;
switch(S){
case 1:
EnterStu_std();
case 2:
EditStu_std();
case 3:
DelStu_std();
case 4:
show_std();
case 5:
Search_std();
case 6:
exit(1);
}
}
}
void EnterStu_std(){
int i, j;
char ch;
clrscr();
for(i=0; i<up; i++){
cout<<“Name Ra Vared Konid: “;
cin>>STD[i].Name;
cout<<“Family Ra Vared Konid: “;
cin>>STD[i].Family;
cout<<“Shomare Daneshjoo: “;
cin>>STD[i].ID;
cout<<“Name Otagh: “;
cin>>STD[i].Otagh;
cout<<“Shomareh Otagh : “;
cin>>STD[i].ShOtagh;
cout<<“Roozaneh / Shabaneh : “;
cin>>STD[i].D_N;
cout<<“Modate sokonat: “;
cin>>STD[i].sokonat;
clrscr();
cout<<“Bazgasht ?”;
if (getch() == ‘y’)
break;
}
MoratabSazi();
menu();
}
void MoratabSazi(){
int temp, i, j;
for(i=0; i<up -1; i++)
for(j=0; j<up – i; i++){
if(STD[i].ID > STD[i + 1].ID){
temp = STD[j].ID;
STD[j].ID = STD[j + 1].ID;
STD[j + 1].ID = temp;
}
}
}
void EditStu_std(){
int i, sId, j;
char ch;
clrscr();
cout<<“Lotfan Shomre Daneshjoee ra Vared konid : “;
cin>>sId;
for(i=0; i<up; i++){
if(sId == STD[i].ID)
break;
}
clrscr();
cout<<“Name:\t”<<STD[i].Name<<“\n”;
cout<<“Family: \t”<<STD[i].Family<<“\n”;
cout<<“Shomare Daneshjoee:\t”<<STD[i].ID<<“\n”;
cout<<“Otagh name:\t”<<STD[i].Otagh<<“\n”;
cout<<“shomareh Otagh:\t”<<STD[i].ShOtagh<<“\n”;
cout<<“Roozane / Shabane:\t”<<STD[i].D_N;
cout<<“sokonat:\t”<<STD[i].sokonat;
cout<<“Aya Mikhahid EditStu Konid ?(y,n)”;
cin>>ch;
switch(ch){
case ‘y’:
{
delete STD[i].Name;
delete STD[i].Family;
STD[i].ID = NULL;
delete STD[i].Otagh;
STD[i].ShOtagh = NULL;
delete STD[i].D_N;
STD[i].sokonat = NULL;
break;
}
case ‘n’:
{
clrscr();
menu();
}
}
clrscr();
cout<<“Etelaate Jadid Ra Vared Konid.\n”;
cout<<“Name Daneshjoo: “;
cin>>STD[i].Name;
clreol();
cout<<“Family : “;
cin>>STD[i].Family;
clreol();
cout<<“Shomare Daneshjoee: “;
cin>>STD[i].ID;
clreol();
cout<<“Name Otagh: “;
cin>>STD[i].Otagh;
clreol();
cout<<“Shomare Otagh : “;
cin>>STD[i].ShOtagh;
clreol();
cout<<“Roozaneh / Shabaneh: “;
cin>>STD[i].D_N;
clreol();
cout<<” sokonat: “;
cin>>STD[i].sokonat;
clreol();
getch();
menu();
}
void DelStu_std(){
int i, sId;
clrscr();
cout<<“Shomare Daneshjoee Ra vared konid .”;
cin>>sId;
for(i=0; i<up; i++){
if(sId == STD[i].ID)
break;
}
delete STD[i].Name;
delete STD[i].Family;
STD[i].ID = NULL;
delete STD[i].Otagh;
STD[i].ShOtagh = NULL;
delete STD[i].D_N;
STD[i].sokonat = NULL;
getch();
menu();
}
void Search_std(){
int i, sId, j;
char ch;
clrscr();
cout<<“Shomare Daneshjoee Ra Vared Konid: “;
cin>>sId;
for(i=0; i<up; i++){
if(sId == STD[i].ID)
break;
}
clrscr();
cout<<” Name:\t”<<STD[i].Name<<“\n”;
cout<<” Family: \t”<<STD[i].Family<<“\n”;
cout<<“Shomare Daneshjoee:\t”<<STD[i].ID<<“\n”;
cout<<“Otagh name:\t”<<STD[i].Otagh<<“\n”;
cout<<“Shomare Otagh:\t”<<STD[i].ShOtagh<<“\n”;
cout<<“Roozaneh / Shabaneh:\t”<<STD[i].D_N;
cout<<“sokonat:\t”<<STD[i].sokonat;
getch();
menu();
}
void show_std(){
clrscr();
int i;
for(i=0; i<up; i++){
cout<<STD[i].Name<<“\t”;
cout<<STD[i].Family<<“\t”;
cout<<STD[i].ID<<“\t”;
cout<<STD[i].D_N<<“\t”;
cout<<STD[i].Otagh<<“\t”;
cout<<STD[i].ShOtagh<<“\t”;
cout<<STD[i].sokonat<<“\t”;
//getch();
}
//menu();
}
|
دیدگاهتان را بنویسید