السلام عليكم
هذا الكود عملته لادخال المعلومات عن المرضي ويقوم بعرضها بس في غلط انه يتكرر العرض وما عاد اقدر ادخل وعملت سويتش للايام بحيث انه اول ما اضغط على اول حرف من ايام الاسبوع على طول يطبع مثال m= mandy or s = saturday
وما عرفت ليش ما يتنفذ
هذا الكود
#include<iostream.h>
#include<process.h>
#include<conio.h>
#include<stdio.h>
#include<dos.h>
class patient_info
{
public:
char name[25];
int day;
char gander;
int no_patient;
int age;
int hours;
int long phone;
void setdata();
void display(int index);
void displayall();
// void update();
// void remove();
void search(int i,int target);
};
patient_info p[2];
void patient_info::setdata()
{
/*1*/ cout<<"please insert the name of patient:. "<<endl;
cin>>name;
/*2*/ cout <<"Enter the number of patient:. "<<endl;
cin>>no_patient;
/*3*/ cout<<"age:. "<<endl;
cin>>age;
/*4*/ cout<<"gander:. ";
cin>>gander;
if (gander=='f')
cout<<"Female\n";
else
{
cout<<"Male\n";
}
/*5*/ cout<<"day:. \n";
cin>>day;
/* switch(day)
{
case 's':
cout<<" Saturday\n";
break;
case 'su':
cout<<" Sunday\n";
break;
case 'm':
cout<<" Manday\n";
break;
case 't':
cout<<"Tuesday\n";
break;
case 'w':
cout<<"Wednesday \n";
break;
case 't':
cout<<"Thursday \n";
break;
case 'f':
cout<<"Friday \n";
break;
default:
cout<<"error";
} */
/*6*/ cout<<"Times:. \n";
if (hours >= 24)
{
day = hours/24;
hours= hours%24;
}
else
day=0;
/*7*/ cout <<" Phone number:."<<endl;
cin>>phone;
}
//******* DISPLAY PATIENT INFORMATION ************
void patient_info::display(int index)
{
cout<<"____________________________________________________\n\n";
cout<<p[index].name<<"I\t"<<p[index].no_patient;
cout<<"I\t"<<p[index].age<<"I\t"<<p[index].gander<<"I\t";
cout<<p[index].day<<"I\t"<<p[index].hours<<"I\t"<<p[index].phone;
}
void patient_info::search(int i,int target)
{
if (p.no_patient==target)
display(i);
}
void patient_info::displayall()
{
cout<<"____________________________\n";
cout<<name<<" "<<no_patient<<" "<<age<<" "<<gander<<" "<<day<<" "<<hours<<" "<<phone;
}
void main()
{
char count;
do
{
clrscr();
int i,j,x;
textcolor(BLUE);
textbackground(RED);
//textattr(210);
clrscr();
gotoxy(10,5);
cout<<"\n\n\t^^ (.'') Welcome to the patient system (.'') ^^";
cout<< endl;
cout<<"\n\n\t^'*~ Choise from this mune ~*^ \n";
cout <<"\n 1- Add the information of patient.";
cout <<"\n 2- Display all Patient. ";
cout <<"\n 3- Search.";
cout <<"\n 4- Update the information.";
cout <<"\n 5- Exit.\n\n";
cout<<"^ Enter your choice ^\n\t";
cin>>i;
switch(i)
{
case 1: //************ add*************
cout <<"\n\n\t\t\tPatient Information...\n";
for ( j=0;j<2;j++)
{
cout <<"\n\nPatient Information # "<<j+1<<"::";
p[j].setdata();
}
break;
case 2: //********calling function to DISPLAY all information **********
cout <<"\n\n\t\ the Patient Information...\n";
cout<<"Name number patient age gander day hour phone \n";
for (int j=0;j<2;j++)
{
p[j].displayall();
}
break;
case 4: //***********SEARCH***********
int nopatient;
clrscr();
cout <<"Enter the number of Patient To search.";
cin>>nopatient;
for(j=0;j<3;j++)
p[j].search(j,nopatient);
if (j>=3)
cout << "\n\n\t\t\tsorry\n\n\t\t\tPatient nopt found.........";
break;
case 5:
exit(1);
break;
default:
getch();
}
sleep(2);
cout <<"\n\n\n If you want to continue press y If no press n.";
cin>>count;
} while(count!='N' && count!='n');
getch();
}اتمنى من الي يعرف المشكله يعلمني واكون شاكره لكم