-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.c
executable file
·119 lines (100 loc) · 1.57 KB
/
update.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "structure.h"
#include <stdio.h>
#include <stdlib.h>
void create()
{
int i,num;
printf("\n How many plates you want in the tower\n HINT-Keep this no. 6 or below\n Otherwise the games gets too much complicated\n ");
scanf("%d",&num);
while(num<1)
{
printf("\n Please enter a positive value\n ");
scanf("%d",&num);
}
ptr1=(node*)malloc(sizeof(node));
start1=ptr1;
for(i=1;i<=num;i++)
{
ptr1->info=i;
if(i!=num)
{
ptr1->next=(node*)malloc(sizeof(node));
ptr1=ptr1->next;
}
else
{
ptr1->next=NULL;
}
}
start3=NULL;
start2=NULL;
}
void display()
{
int i;
ptr1=start1;
ptr2=start2;
ptr3=start3;
printf("\n Tower 1\n\n ");
while(ptr1!=NULL)
{
i=1;
while(i<=ptr1->info)
{
printf("*");
i++;
}
printf("\n ");
ptr1=ptr1->next;
}
printf("\n Tower 2\n\n ");
while(ptr2!=NULL)
{
i=1;
while(i<=ptr2->info)
{
printf("*");
i++;
}
printf("\n ");
ptr2=ptr2->next;
}
printf("\n Tower 3\n\n ");
while(ptr3!=NULL)
{
i=1;
while(i<=ptr3->info)
{
printf("*");
i++;
}
printf("\n ");
ptr3=ptr3->next;
}
printf("\n");
}
node* deletenode(node *s)
{
node *p=s;
s=p->next;
return(p->next);
}
node* insertnode(node *s,int n)
{
node *p=s,*nptr;
nptr=(node*)malloc(sizeof(node));
if(p==NULL)
{
nptr->info=n;
nptr->next=NULL;
s=nptr;
return(nptr);
}
else
{
nptr->info=n;
nptr->next=p;
s=nptr;
return(nptr);
}
}