-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignment4.c
115 lines (90 loc) · 1.92 KB
/
Assignment4.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
#include<stdio.h>
#include<stdlib.h>
typedef struct
{
int score;
int lives;
char lessGreaterMessage[50];
char winFailMessage[50];
struct StepReport *nextNode;
}StepReport,*NodePtr;
int main()
{
char lessGreaterMessage[50];
char winFailMessage[50];
srand (time(NULL));
int random_number = (rand() % 100)+1;
StepReport top[10];
StepReport *top;
strcpy(top[0].score, 100);
strcpy(top[0].lives,10);
strcpy(top[0].lessGreaterMessage,"Please start the game");
strcpy(top[0].winFailMessage,"Good Luck!");
do
{
struct StepReport *new_node,*current;
printf("nEnter your guess : ");
scanf("%d",&new_node->data);
new_node->next=NULL;
if(start==NULL)
{
start=new_node;
current=new_node;
}
else
{
current->next=new_node;
current=new_node;
}
printf("nDo you want to creat another : ");
ch=getche();
}while(lives != 0);
// StepReport *top;
// countNumberOfNodes(top);
// printf("%d",countNumberOfNodes(top));
// char lessGreaterMessage[50];
// char winFailMessage[50];
//
// StepReport top[10];
//
// strcpy(top[0].score, 100);
// strcpy(top[0].lives,10);
// printf("hello");
// strcpy(top[0].lessGreaterMessage,"Please start the game");
// strcpy(top[0].winFailMessage,"Good Luck!");
// printf("%s",&top[0].lessGreaterMessage);
system("pause");
}
//return the number of node int the list
int countNumberOfNodes(NodePtr top)
{int n=0;
NodePtr curr=top;
while (curr != NULL)
{
n++;
curr=curr -> nextNode;
}
return n;
}
//search the list to get the value
//Nodeptr serach(NodePtr top; int val)
//{
// while (top != NULL && val != top -> nodeData)
// {
// top=top->next;
// }
// return top;
//}
//get the last node from the list
//Nodeptr getLast(NodePtr top)
//{
//if(top == NULL)
//{
// return NULL;
//}
//while()
//{
// top = top -> next;
//}
//return top;
//}