i have a struct
Code:
typedef struct item{
int number; //the number
int occur; // the number of ocuurances of this number
struct item *next;
}item;
i need to compete the gaps of the following structure
so it will reduse the duplicates of a certain item in the original list
and puts the total number of the occurances of a item into its item.number struct.
for example
http://i39.tinypic.com/1z3016p.gif
Code:
void reduce(item *head){
item* temp;
int count = ?? 1 ??;
if ?? 2 ?? ;
while(?? 3 ??)
if( ?? 4 ?? ){
?? 5 ??;
?? 6 ??;
?? 7 ?? ;
count++;
}
else{
head->occur = count;
?? 8 ?? ;
?? 9 ?? ;
}
?? 10 ?? ;
}
i tried to fill some but i can see what each block of the given structure should do in general
Code:
void reduce(item *head){
item* temp;
int count = 0;
if (!head) return;
while(temp)
if(head->number==head->next->number ){
temp=head->next;
head->next=head->next->next;
free(temp) ;
count++;
}
else{
head->occur = count;
head=head->next;
?? 9 ?? ;
}
?? 10 ?? ;
}
i tried to fill some but i can see what each block of the given structure should do in general