// dinam4.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
struct rec{
       int num;
       rec *pred,*next;};
void main()
   {rec *first,*q,*p,*last;
    int i,n;
srand( (unsigned)time( NULL ) );
    first=new rec;
	first->pred=NULL;
	first->next=NULL;
	 first->num=rand()/100;
   puts("Input value n<=100 Chetnoe");
	 scanf("%d",&n);
	 p=first;
    for (i=1;i<n;i++){
       q=new rec;
       q->num=rand()/100;
	   q->next=NULL;
	   q->pred=p; 
	   p->next=q;     
       p=q;
       }
	last=p;
	puts("Spisok");
       q=first;
    while(q!=NULL){
       printf("%5d",q->num);
       q=q->next;}
	printf("\n");
	puts("Spisok bakup");
       q=last;
    while(q!=NULL){
       printf("%5d",q->num);
       q=q->pred;}
	printf("\n");
puts("Input maxel");
p=first;
q=last;
while(p!=q->next)
{if(p->num>q->num)
   printf("%4d",p->num);
else printf("%4d",q->num);
  p=p->next;
  q=q->pred;
}
   printf("\n");
 }
