This is my objective for this program
Objective:
Use the IntNode class (that you saw in Lab 10) to construct a linked
list that looks like
first -> 5 -> 7 -> 3 -> 5 -> 7 -> 3 -> ... -> 5 -> 7 -> 3
where the 5 7 3 subsequence occurs 100 times.
the IntNode class just contains a int value that holds a number and a point to the next node.
My question is on the fact that the sequence occurs 100 times.
I was thinking maybe I make another temp linked list and everytime i put a value in its node i make first point to the initial node of the temp linked list.
I'm not getting the right output though. I'm getting like 5, 0 and that's it
Any suggestions? Thanks!
Objective:
Use the IntNode class (that you saw in Lab 10) to construct a linked
list that looks like
first -> 5 -> 7 -> 3 -> 5 -> 7 -> 3 -> ... -> 5 -> 7 -> 3
where the 5 7 3 subsequence occurs 100 times.
the IntNode class just contains a int value that holds a number and a point to the next node.
My question is on the fact that the sequence occurs 100 times.
I was thinking maybe I make another temp linked list and everytime i put a value in its node i make first point to the initial node of the temp linked list.
int values[] = { 5, 7, 3 };
first = new IntNode();
int count=0;
IntNode temp=null;
for (int i = 0; i < 100; i++)
{
if(count>2)
count=0;
temp.next = new IntNode();
temp.value = values[count];
first = temp;
count++;
}
I'm not getting the right output though. I'm getting like 5, 0 and that's it
Any suggestions? Thanks!