#include "stdio.h"
#include <stdlib.h>
struct node {
char data;
struct node *next;
};
void dellink(struct node *h); // 释放链表的函数
struct node *createlink();
struct node *findbypos(struct node *h, int pos);
main() {
struct node *p, *head = NULL;
int d;
head = createlink();
scanf("%d", &d);
p = findbypos(head, d);
putchar(p->data);
dellink(head); // 释放链表
}
struct node *createlink() {
struct node *head = NULL, *p, *q;
char ch;
while (ch = getchar(), ch!= '#') {
p = (struct node *)malloc(sizeof(struct node));
p->data = ch;
p->next = NULL;
if (head == NULL) {
head = p;
q = p;
} else {
q->next = p;
q = p;
}
}
return head;
}
struct node *findbypos(struct node *h, int pos) {
struct node *p = h;
int count = 1;
while (p!= NULL && count < pos) {
p = p->next;
count++;
}
return p;
}
void dellink(struct node *h) {
struct node *q;
while (h!= NULL) {
q = h;
h = h->next;
free(q);
}
}