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

مساعده في برنامج سي بلس بلس

بدأه حويسبه في 18 مايو 2009 · 0 رد · 185 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#1

مرحبا

اتمنى من اللي يقدر يسااااااااعدني بلييييييييييييييييز كودا هذا البرنامج

واريد تحويله لبرنامج يقوم حفظبيانات اكثر من كتاب عن طريقه مصفوفه من الاوبجيكت وويفر الخدمات التاليه عن طريق قائمه يختار منه المستخدم

عرض بيانات اكتب

البحث عن كتاب معين تبعا لاسم الكتاب والرقم الكتاب

حذف كتاب

مع ملاحظة التالي

تكرار الاوامر المتاحه الى ان يطلب المستخدم الخروج من البرنامج

اذا كان سيختار حرف من قائمه يراعي الحروف الصغيره والكبيره

ان نعطي المصفوفه قيم افتراضيه بمجرد انشائها

(لو اردنا تنفيذ نفس الربنامج لكن من خلال المؤشرات )

void init_list();

int menu();

void enter();

void input(int i);

void update();

void display();

const int SIZE=20;

struct Book

{

char Title;

int ID;

int Quantity;

float cost;

}Library[20];

int main()

{

char choice;

init_list();

for(;;)

{

choice = menu();

switch(choice)

{

case 'e':

enter();

break;

case 'd':

display();

break;

case 'u':

update();

break;

case 'q':

return 0;

}

}

getch();

}

// Initialize the array.

void init_list()

{

int t;

for(t=0; t<SIZE; t++)

*Library[t].Title = '\0';

}

// Get a menu selection.

int menu()

{

char ch;

cout << '\n';

do {

cout << "\n\t\t(E)nter\n";

cout << "\n\t\t(D)isplay\n";

cout << "\n\t\t(U)pdate\n";

cout << "\n\t\t(Q)uit\n\n";

cout << "\n\t\t\tchoose one: ";

cin >> ch;

} while(!strchr("eduq", tolower(ch)));

return tolower(ch);

}

// Enter Titles into the list.

void enter()

{

int i;

// find the first free structure

for(i=0; i<SIZE; i++)

if(!*Library.Title)

break;

// i will equal SIZE if the list is full

if(i==SIZE)

{

cout << "List full.\n";

return;

}

input(i);

}

// Input the information.

void input(int i)

{

// enter the information

cout << "\n\tBook Title: ";

gets(Library.Title);

cout << "\n\tBook ID: ";

cin >> Library.ID;

cout << "\n\tBook price: ";

cin >> Library.cost;

cout << "\n\tBook Quantity: ";

cin >> Library.Quantity;

}

// Modify an existing Title.

void update()

{

int i;

char name[80];

cout << "Enter Title: ";

cin >> name;

for(i=0; i<SIZE; i++)

if(!strcmp(name, Library.Title))

break;

if(i==SIZE)

{

cout << "\n\t\tTitle not found.\n";

return;

}

cout << "\n\tEnter new information.\n";

input(i);

}

// Display the list.

void display()

{

int t;

for(t=0; t<SIZE; t++)

{

if(*Library[t].Title)

{

cout << "\n\tBook Title: "<<Library[t].Title;

cout << "\n\tBook ID: "<<Library[t].ID;

cout << "\n\tBook price: "<<Library[t].cost;

cout << "\n\tBook Quantity: "<<Library[t].Quantity;

}

}

}

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