// dinam5.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 *p;};
void main()
   {rec *first,*q,*p;
    int i,n;
srand( (unsigned)time( NULL ) );
    first=new rec;
	first->p=NULL;
	 first->num=rand()%100+1;
   	 n=rand()%50+10;
	 p=first;
    for (i=1;i<n;i++){
       q=new rec;
       q->num=rand()%100+5;
	   q->p=NULL;
	   p->p=q;     
       p=q;
       }
	puts("Spisok");
       q=first;
    while(q!=NULL){
       printf("%5d",q->num);
       q=q->p;}
	printf("\n");
	puts("input value for udal");
    scanf("%d",&n); 
    while((first!=NULL)&&(first->num%n==0))
	{ p=first;
	first=first->p;
	delete(p);}
	if (first==NULL)
     puts("Spisok Empty");
	else
	{
	  p=first;
	  q=first;
	  do{	  
       if(q->num%n==0)
	   {p->p=q->p;
        delete(q);
		q=p->p;}
	   else
	   {p=q;
	   q=q->p;}
	   } while (q!=NULL);

    puts("New Spisok");
       q=first;
    while(q!=NULL){
       printf("%5d",q->num);
       q=q->p;}
	printf("\n");
   }
 }
