1 typedef struct Link 2 { 3 int data; 4 struct Link* next; 5 }NODE,*pNODE;
1 NODE *searchK(NODE *phead, int k) 2 { 3 pNODE pcur = phead, ppre = phead; 4 int cnt = 0; 5 if(phead == NULL || k == 0) 6 return NULL; 7 8 while(pcur != NULL) 9 { 10 ++cnt; 11 if(cnt > k) 12 ppre = ppre->next; 13 pcur = pcur->next; 14 } 15 if(cnt < k) 16 return NULL; 17 else 18 return ppre; 19 }