الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

عندي غلط بالكود

مغلق
بدأه soso_d في 17 أبريل 2006 · 3 رد · 640 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

هذا الكود عملته لادخال المعلومات عن المرضي ويقوم بعرضها بس في غلط انه يتكرر العرض وما عاد اقدر ادخل وعملت سويتش للايام بحيث انه اول ما اضغط على اول حرف من ايام الاسبوع على طول يطبع مثال 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();
  }

اتمنى من الي يعرف المشكله يعلمني واكون شاكره لكم

#2

أول خطأ فى ذلك السطر

cout <<"\n\nPatient Information # "<<j+1<<"::";

Abmigious Error

الcompiler مش عارف يميز ما بين ال>> and + مش عارف يجمع ولا أية والحل

  cout <<"\n\nPatient Information # "<<(j+1)<<"::";

أما باقى الاخطاء سبب أكتر من سطر داخل الcase الواحدة وتعريف بعض المتغيرات داخل الdo-whileوأيضا تعريف متغير(مش متذكر إسمة أعتقدnopatient) داخل case 4 وبالتالى سيصبح التصحيح كما يالى

   void main()
{
 char count;
 int nopatient;
   int i,j,x;
  do
  {
    clrscr();

  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:
   {
     cout <<"\n\n\t\t\tPatient Information...\n";
     for ( j=0;j<2;j++)
     {
      cout <<"\n\nPatient Information # "<<(j+1)<<"::";
      p[j].setdata();
     }
   }               //************ add*************

   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 kj=0;kj<2;kj++)
    {
      p[kj].displayall();

    }
   }
   break;

  case 4:
  {
    clrscr();
    cout <<"Enter the number of Patient To search.";
     cin>>nopatient;

    for(j=0;j<2;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();
 }

مع العلم الكدو صعب فهمة وقرائتة لافتقادة التنظيم وعدم تعريف المتغيرا بأسماء دالة ع عملها وعدم إستخدام الOOP بطريقة صحية

أتمنى أن أكون صححت الاخطاء ووضحت بعض العيوب وبالتوفيق بأذن الله

Muhammad Allam

Computer Science

@Resource(MappedURL="My Blog" )

#3

thanks eng_3llam

yes i have alot of error i was create the data type of day int and i want to print characters

this si the ones

there'er alot i'm trying to discover the error

thanks

#4

thanks

تم تعديل هذه المشاركة بواسطة soso_d في 18 أبريل 2006 في 12:11

هذا الموضوع مغلق.

مواضيع مشابهة