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

الله يخليكم ساعدوني في هذا البرنامج

مغلق
بدأه كلي حلااااااااا في 23 نوفمبر 2004 · 1 رد · 383 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

اول شي السلااااااااام عليكم كلللللللللللللكم

وهذا البرنامج المطلوب

[ Write a menu driven program to implement a singly linked list for storing parts data.

Parts data is made out of:

Part number

Part name

Price

The program should provide the operations for:

1. Creating a list of parts data.

2. Sorting the list of parts data.

3. Merging two lists of parts data into a new list.

4. Displaying the contents of a parts data list.

Make sure that the events happen in the correct order, and accurate messages are displayed incase of error.

وانا بديت بالحل وحليت فقرة الاولى والاخيرة والحمد لله طلع صح بس باقي الفقرة الثانيه والثالثه

الله يخليك شوفوا لي حل مستعجل لأن لازم اسلمه قبل يوم الاربعاء ايه صح نسيت اقولكم حل البرنامج بلغ سي

وهذا حلي

#include<stdio.h>

#include<stdlib.h>

struct listNode{

int number;

char name;

int price;

struct listNode *nextPtr;

};

typedef struct listNode listNode;

typedef listNode *listNodePtr;

void instructions(void);

void insert(listNodePtr*,int,char,int);

void printList(listNodePtr);

int main()

{

listNodePtr startPtr=NULL;

int choice;

int number;

char name;

int price;

instructions();

printf("?");

scanf("%d",&choice);

while(choice !=2){

switch(choice){

case 1:

printf("Enter parts data:\n");

scanf("%d %c %d",&number,&name,&price);

insert(&startPtr,number,name,price);

printList(startPtr);

break;

default:

printf("Invalid choice.\n\n");

instructions();

break;

}

printf("\n?");

scanf("%d",&choice);

}

printf("End of run.\n");

return 0;

}

void instructions(void){

printf("Enter your choice:\n"

" 1 to insert an elemant into the list.\n"

" 2 TO END.\n");

}

void insert(listNodePtr *sPtr,int num,char N,int pri)

{

listNodePtr newPtr,previousPtr,currentPtr;

newPtr=malloc(sizeof(listNode));

if(newPtr!=NULL){

newPtr->number=num;

newPtr->name=N;

newPtr->price=pri;

newPtr->nextPtr=NULL;

previousPtr=NULL;

currentPtr=*sPtr;

while(currentPtr!=NULL)

{

previousPtr=currentPtr;

currentPtr=currentPtr->nextPtr;

}

if(previousPtr==NULL)

{

newPtr->nextPtr=*sPtr;

*sPtr=newPtr;

}

else{

previousPtr->nextPtr=newPtr;

newPtr->nextPtr=currentPtr;

}

}

else

printf("%c not inserted.");

}

void printList(listNodePtr currentPtr)

{

if(currentPtr==NULL)

printf("list is Empty.\n\n");

else

{

printf("The list is :\n");

while(currentPtr!=NULL){

printf("%d-->%c-->%d-->",currentPtr->number,currentPtr->name,currentPtr->price);

currentPtr=currentPtr->nextPtr;

}

printf("NULL");

}

}

#2

موضوع مخالف و لا اعتقد ان هناك احد احد يعارضني و بعد اذن مشرفي القسم سوف يغلق الموضوع...

و ارجو منك التقيد بقواعد المشاركة... و اهلا بك معنا و لكن دون مخالفات

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

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

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