c - Numbering Elements in a Linked List of structs -
I am trying to write a task that takes a logical form that is a linked list of strokes. One of the elements of these strokes is a value to accumulate a situation, for instance the structure is # 3 for element 3. The list that comes in is not in the order. I want to go through each element in the linked list and I want to set the price based on that sequence. How do i do this
Nodt number strikes (nodt * temporary) {int i; I = 0; While (temp! = NULL) {temp-> Struct.struct_order = i; Temporary = temp-> Next; I ++; } Return temporary; } This is not going to clearly cut it, but this is what I have so far received. Apart from this, to clarify, I am adding elements, adding elements, removing elements. Every time it matters that anything changes in the line order, I want to call a function to straighten them. This allows me to change the pointers of linked list structures whenever I want to make changes.
typedef struct nodeT {struct node * next; Int struct_order; ...} NodeT; Zero fill_idx (NodeT * first) {int idx; Nodtie * node; For (node = first, idx = 0; node; node = node-> next, ++ idx) {node-> Straight_order = idx; }} Symmetry, with a little loop:
zero fill_idx (NodeT * first) {int idx = 0; Nodt * node = first; While (node) {node-> Straight_order = idx; Node = node-> next; ++ IDX; }}
Comments
Post a Comment