-
Website
http://blog.jploh.com/ -
Original page
http://blog.jploh.com/2007/07/20/bad-apples-contd/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
ARKOOOLZ
1 comment · 1 points
-
mc_hamer
3 comments · 1 points
-
barz
2 comments · 1 points
-
Craigslist Proxy
2 comments · -1 points
-
wildquaker
1 comment · 1 points
-
-
Popular Threads
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct list
{
int data;
struct list *next;
};
typedef struct list node;
void init(node* record)
{
record->next=NULL;
}
void addnode(node* record,int d)
{
node* fresh;
fresh=(node *)malloc(sizeof(node));
fresh->data=d;
fresh->next=record->next;
record->next=fresh;
}
void print(node *record)
{
node* temp;
temp=(node *)malloc(sizeof(node));
for(temp=record->next;temp;temp=temp->next)
printf(" %d",temp->data);
}
void reverse(node* record)
{
node* temp;node* temp1;node* temp2;
temp=(node *)malloc(sizeof(node));
temp1=(node *)malloc(sizeof(node));
temp2=(node *)malloc(sizeof(node));
temp=record;temp1=temp->next;temp2=temp1->next;
temp->next->next=NULL;
while(temp2!=NULL)
{
temp=temp1;
temp1=temp2;
temp2=temp1->next;
temp1->next=temp;
}
record->next=temp1;
}
int main(void)
{
node* start;
node* start1;
start=(node *) malloc(sizeof(node));
init(start);
int i=0;
for(i=10;i>=0;i--)
addnode(start,i);
getch();
print(start);
getch();
reverse(start);
getch();
print(start);
getch();
return 0;
}