自己写的。不用链表题解 | #输出单向链表中倒数第k个结点#
输出单向链表中倒数第k个结点
https://www.nowcoder.com/practice/54404a78aec1435a81150f15f899417d
#include<stdio.h> int main() { int line[1000]; int res[100]; int n, k, i, count = 0; while (scanf("%d", &n) > 0) { for (i = 0; i < n; i++) { scanf("%d", &line[i]); } scanf("%d", &k); if (k < 0 || k > n) { res[count++] = 0; } else { res[count++] = line[n - k]; } for (i = 0; i < 1000; i++) { line[i] = 0; } } for (i = 0; i < count; i++) { printf("%d\n", res[i]); } return 0; }