guys a new guy have just popped in from somewhere. he is new i mean very new. he only need some welcome messages from all the members so he will feel like he have entered the right site. His name is EDDY a COMPUTER SCIENCE student at the Univesity of ZIMBABWE. he is a cool guy ,just try to do as he said.
this might seem out of topic but i had to do this.
i hope u will respond.
thanks guys.
for private msgs use r076623j@cs.uz.ac.zw
C U THERE
|
Go4Expert Founder
|
![]() |
| 6Jun2008,22:40 | #2 |
|
welcome
|
|
Ambitious contributor
|
|
| 7Jun2008,05:43 | #3 |
|
hehey! welcome!
like your avatar computer science? oh wow sounds great, hows it goin? |
|
Light Poster
|
|
| 9Jun2008,17:39 | #4 |
|
im happy to have a respond from u guy, i love it. i have a problem to share with you. i ws given an assignment on double linked list to do a multipe tasks. i coded it but i was left with 5 errors i couldnt resolve. the program is like this
Code:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define NULL 0
struct list
{
int data;
struct list*next;
struct list *prev;
};
typedef struct list node;
node *find(node *,int);
node *pre=NULL;
node *fin=NULL;
node *start;
int main()
{
int menu(void);
void create(node *);
void display(node *);
void insert(node *,int,int);
void revdisplay(node *);
void del(node *,int);
int choice,ch;
int data,tar;
node *newrec;
start=NULL;
do
{
clrscr();
choice=menu();
switch(choice)
{
case '1':
printf("\nCreating the list");
printf("Enter the terms(type 0 to end)\n");
start=new node;
create(start);
break;
case '2':
if (start==NULL)
printf("\nList does not exist");
else
{
printf("\nDisplaying the list\n");
display(start);
getch();
}
break;
case '3':
if (start==NULL)
{
printf("\nList does not exist");
getch();
}
else
{
printf("\nDisplaying the list:");
revdisplay(fin);
}
case '4':
if(start==NULL)
{
printf("\nList does not exist");
getch();
}
else
{
printf("\nEnter the term to insert:");
scanf("%d",&data);
printf("\nEnter target term:");
scanf("%d",&tar);
insert(start,data,tar);
}
break;
case '5':
if(start==NULL)
{
printf("\nlist does not exist:");
getch();
}
else {
printf("\nEnter the term to delete:");
scanf("%d",&data);
del(start,data);
}
break;
case '6':
printf("\nExiting" );
break;
default:
printf("\nNot a valid choice");
getch();
break;
}
}
while(choice!=6);
getch();
return(0);
}
int menu(void)
{
int ch;
printf("\n1->Creation of the list");
printf("\n2->Displaying of the list");
printf("\n3->Displaying the list");
printf("\n4->Insertion of the list");
printf("\n5->Deletion of the list");
printf("\n6->Reverse of the list");
printf("\n7->Exit");
printf("\nEnter your choice:");
scanf("%d",ch);
return(ch);
}
void create(node *record)
{
scanf("%d",&record->data);
if(record->data==0)
{
record->next=NULL;
record->prev=pre;
fin=record->prev;
pre=NULL;
}
else
{
record->prev=pre;
record->next=new node;
pre=record;
create(record->next);
}
return;
}
void display(node *record)
{
if(record->next!=NULL)
{
printf("%d",display(record->next));
}
return;
}
void reverse(node *record)
{
if(record!=NULL)
{
printf("%c",display(record->prev));
}
return;
void insert(node *record,int data,int target)
{
node *tag,*newrec,*temp;
newrec=new node;
if(record->data==target)
{
newrec->next=record;
newrec->prev=NULL;
record->prev=newrec;
start=newrec;
}
else
{
tag=find(record,target);
temp=tag->prev;
tag->prev=newrec;
newrec->next=tag;
temp->next=newrec;
}
if(tag==NULL)
{
printf"Target item not present in the list\n");
getch();
return;
}
newrec->data=data;
return;
}
void del(node *record,int target)
{
node *tag,*temp;
if(record->data==target)
{
temp=record;
start=start->next;
start->prev=NULL;
delete temp;
}
else
{
tag=find(record,target);
if(tag->next->next==NULL)
{
fin=fin->prev;
fin->next=tag->next;
}
if(tag==NULL)
{
printf("Target item not present in the list\n");
getch();
return;
}
return;
}
node *find(node *record,int target)
{
if(record->next->data==target)
{
return(record);
}
else if(record->next==NULL)
return(NULL);
else
find(record->next,target);
}
}
hope u will help me to make it run Last edited by shabbir; 9Jun2008 at 18:08.. Reason: Code block |
|
Go4Expert Founder
|
![]() |
| 9Jun2008,18:09 | #5 |
|
Quote:
Originally Posted by gunshot08 |
