// Dinspst.cpp: определяет точку входа для консольного приложения.
//

#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
struct rec{
       int num;
       rec *p;};
void main()
   {rec *first,*q,*p;
    int i,j,n;
	char s[80],s1[10];
	j=0;i=0;s1[j]='\0';
	puts("Input string with value");
	gets(s);
first=NULL;
while(i<=strlen(s))
{  if((s[i]==' ')||(s[i]=='\0'))
    { 
		s1[j]='\0';
        if (first==NULL)
		{ 
			first=new rec;
	        first->p=NULL;
	        first->num=atoi(s1);
			p=first;
		}
		else
		{  q=new rec;
	        q->p=NULL;
	        q->num=atoi(s1);
			p->p=q;
			p=q;
		}
		j=0;s1[j]='\0';
     }
    else
	{s1[j]=s[i];
      j++;}
  i++;
}
puts("Inputed value ");
q=first;n=0;
while (q!=NULL)
{printf("%5d\n",q->num);
  q=q->p;n++;
}
printf("\n");int k;
do {printf("Input k<=%5d\n",n);
scanf("%d",&k);
}while (k>n);
i=1;
if (k==1)
{p=first;first=first->p;
 delete p;}
else
 {
	 p=q=first;
	 while(i!=k) 
	 { p=q;
	   q=q->p;
	   i++;
	 }
       
	 p->p=q->p;     
      delete q;
  }
	puts("Spisok");
       q=first;
    while(q!=NULL){
       printf("%5d",q->num);
       q=q->p;}
	printf("\n");
getch();
  
 }
