//MIN_INT= -32768
//iterative function
max(Node *p){
int m= INT32_MIN;
while(p){
if(p->data > m)
m=p->data;
p=p->next;
}
return m;
}
//recursive function
max(Node *p){
int x=0;
if(p==0)
return INT32_MIN;
else
x= max(p->next);
if(x>p->data)
return x;
else
return p->data;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter