P
placid
Thanks everyone i got it to work at last but how would we resolve
numbers inside a integer linked-list and ive been writing out
flow-chart for this problem but i cant seem to be getting my head
around it
here is a code that i wanted
typedef struct intnode
{
int data;
struct intnode *next;
}IntNode;
typedef struct listhead
{
IntNode *head;
int count;
}ListHead
.....
void printList(ListHead * lh)
{
IntNode *current = lh->head;
int prevNum =0, x=0;
while (current != NULL)
{
if (prevNum > 0)
{
if( (prevNum+1) == current->data)
{
if(x==0)
{
printf("-");
x=1;
}
}
else if( (prevNum+1) != current->data)
{
printf("%s,%s",prevnum,current->data);
x=0; /* To display '-' for next series of numbers */
}
}
}
prevNum = current->data;
current = current->next;
}
}
the problem i think was i was thinking of a solution to this problem if
arrays where used now that i want to change it to LL structure im
confused, so any help will be appreciated again
numbers inside a integer linked-list and ive been writing out
flow-chart for this problem but i cant seem to be getting my head
around it
here is a code that i wanted
typedef struct intnode
{
int data;
struct intnode *next;
}IntNode;
typedef struct listhead
{
IntNode *head;
int count;
}ListHead
.....
void printList(ListHead * lh)
{
IntNode *current = lh->head;
int prevNum =0, x=0;
while (current != NULL)
{
if (prevNum > 0)
{
if( (prevNum+1) == current->data)
{
if(x==0)
{
printf("-");
x=1;
}
}
else if( (prevNum+1) != current->data)
{
printf("%s,%s",prevnum,current->data);
x=0; /* To display '-' for next series of numbers */
}
}
}
prevNum = current->data;
current = current->next;
}
}
the problem i think was i was thinking of a solution to this problem if
arrays where used now that i want to change it to LL structure im
confused, so any help will be appreciated again