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

مساعده

بدأه الوجدان في 4 نوفمبر 2009 · 2 رد · 368 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكــم ورحمـة الله وبركاتــه ،،

كيف حالكم إن شاء الله دائمــاً بخير ؟

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

ولقيت هذا في النت بس ماادري صح او لا لان ماعندي خلفيه في الانجليزي اتمنى المساعده ..؟؟


{
int info;
struct node *link;
} *top=NULL;

main()
{
int choice;
while(1)
{ printf("1.Push\n");
printf("2.Pop\n");
printf("3.Display\n");
printf("4.Quit\n");
printf("Enter your choice : ");
scanf("%d", &choice);

switch(choice)
{
case 1:
push();
break;
case 2:
pop();
break;
case 3:
display();
break;
case 4:
exit(1);
default :
printf("Wrong choice\n");
}/*End of switch */
}/*End of while */
}/*End of main() */

push()
{
struct node *tmp;
int pushed_item;
tmp = (struct node *)malloc(sizeof(struct node));
printf("Input the new value to be pushed on the stack : ");
scanf("%d",&pushed_item);
tmp->info=pushed_item;
tmp->link=top;
top=tmp;
}/*End of push()*/

pop()
{
struct node *tmp;
if(top == NULL)
printf("Stack is empty\n");
else
{ tmp=top;
printf("Popped item is %d\n",tmp->info);
top=top->link;
free(tmp);
}

}/*End of pop()*/

display()
{ struct node *ptr;
ptr=top;
if(top==NULL)
printf("Stack is empty\n");
else
{
printf("Stack elements :\n");
while(ptr!= NULL)
{
printf("%d\n",ptr->info);
ptr = ptr->link;
}/*End of while */
}/*End of else*/
}/*End of display()*/
struct node

تم تعديل هذه المشاركة بواسطة Wajdy Essam في 5 نوفمبر 2009 في 21:22

#2

وعليكم السلام ورحمة الله وبركاته ..

بصراحه أختي الكود ملخبط :wacko: ولا قدرت أقرأه ..

على العموم , هذا كود للـ Stack Using Linked_List

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

struct node
{
	int data;
	struct node *link;
};
struct node *top=NULL,*temp;

void main()
{
int choice,data;
clrscr();
while(1)
{
printf("\n1.push\n2.Pop\n3.Display\n4.Exit\n"); 
printf("\nEnter ur choice:");
scanf("%d",&choice);
switch(choice)
{
 case 1:
		 temp=(struct node *)malloc(sizeof(struct node));
		 printf("Enter a node data :");
		 scanf("%d",&data);	
		temp->data=data;
		temp->link=top; 
		top=temp;  
		break;
case 2:
	  if(top!=NULL)
	{
	  printf("The poped element is %d",top->data);
	  top=top->link;
	}
	else 
	{
	 printf("\nStack Underflow");
	}
	 break;
case 3:
	  temp=top;
	  if(temp==NULL)
	  { 
	   printf("\nStack is empty\n");
	  }
	  while(temp!=NULL)
	 {
	  printf("->%d->",temp->data); 
	  temp=temp->link;
	 }
	break;
 case 4:
exit(0);

 }
   }
}

اقتباس
لان ماعندي خلفيه في الانجليزي

أتوقع قصدك أنك مو فاهمه وش يقصد بـ Pop , Push ,Top ?

أعذريني إذا كنت غلطانه ..

بالتوفيــــــق :happy:

تم تعديل هذه المشاركة بواسطة إشراقــه فجــر في 5 نوفمبر 2009 في 01:47

سبحآن الله وبحمده .. سبحآن الله العظيم .. ,

#3

اشراقة فجر

الف شكر لمساعدتك.. وانا قصدي اني خفت اعطي البرنامج الاستاذه ومايكون هو المطلوب لاني نصف فاهمه stack بس الله ييسر لنا

لكـ الود والاحتــراااامـ ..""

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