#include<stdio.h>
#include<stdlib.h>
#define OK 1
#define ERROR -1
typedef int Status;
typedef int ElemType;
typedef struct LNode{
ElemType data;
struct LNode *next;
}LNode,*LinkList;
Status InitList(LinkList &L){
L = new LNode;
L->next = NULL;
return OK;
}
void CreateList(LinkList &L,int m){
LinkList t;
printf("请输入数值:");
for(int p = 0 ; p < m ; p++){
t = new LNode;
scanf("%d",&t->data);
t->next = L->next;
L->next = t;
}
}
void CreateList_1(LinkList &L){
LinkList t;
ElemType data;
printf("请输入数值:");
while (1){
scanf("%d",&data);
if (data =='\n') break;
t = new LNode;
t->data = data;
t->next = L->next;
L->next = t;
}
}
int GetMax(LinkList L){
LNode *pmax,*p;
if(L->next == NULL)
return NULL;
pmax = L->next;
p = L->next->next;
while (p){
if(p->data > pmax->data)
pmax = p;
p = p->next;
}
return (pmax->data);
}
int main(){
int n,a;
LinkList L,L1;
InitList(L1);
CreateList_1(L1);
a=GetMax(L1);
printf("最大结点:%d\n",a);
return 0;
}