#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
int main()
{
struct node *head = NULL, *p = NULL, *max_node = NULL;
int num = 0, max_num = -2147483647; // 假设输入的整数不超过-2147483647
// 输入若干个整数,以-1作为输入结束
while (1)
{
scanf("%d", &num);
if (num == -1)
{
break;
}
p = (struct node *)malloc(sizeof(struct node)); // 创建新节点
p->data = num;
p->next = head;
head = p;
}
// 求最大值
for (p = head; p != NULL; p = p->next)
{
if (p->data > max_num)
{
max_num = p->data;
max_node = p;
}
}
// 输出结果
if (max_node == NULL) // 如果不存在最大值
{
printf("No answer!\n");
}
else // 如果存在最大值
{
printf("%d\n", max_num);
}
return 0;
}