题目地址:https://pintia.cn/problem-sets/15/problems/727
题目输入最后一个-1代表输入结束,所以查询位置6的结果是NA
ElementType FindKth(List L, int K) { List p = L; int cnt = 0; while(p) { cnt++; if(cnt == K) { return p->Data; } p = p->Next; } return ERROR; }
题目地址:https://pintia.cn/problem-sets/15/problems/727
题目输入最后一个-1代表输入结束,所以查询位置6的结果是NA
ElementType FindKth(List L, int K) { List p = L; int cnt = 0; while(p) { cnt++; if(cnt == K) { return p->Data; } p = p->Next; } return ERROR; }