Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

prg-sem-sp / 2 / Задача30

.CPP
Скачиваний:
13
Добавлен:
28.03.2015
Размер:
851 б
Скачать
// “¤ «Ґ­ЁҐ «Ёи­Ёе бЁ¬ў®«®ў
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <alloc.h>
#include <string.h>
# define ENTER 13
void main (void)
 {int n=80,index,j,max=0;
  char ch,*txt=(char*)calloc(n,sizeof(char));
  clrscr();
  puts("ENTER-Є®­Ґж ўў®¤ ");
  for(index=0;(ch=getche())!=ENTER;index++)
    {if(index==n-1){n+=80;txt=(char*)realloc(txt,n*sizeof(char));}
    txt[index]=ch;
    }txt[index]=NULL;
  puts("\n‚ и ⥪бв:");puts(txt);
  index=0;max=strlen(txt);
  while(txt[index]!=NULL && index++<max)
  {if(txt[index]==' '||txt[index]==';'||txt[index]==','||txt[index]=='-'||txt[index]=='.')
   {if(txt[index-1]==' ')
    {for(j=index;j<max;j++)
     txt[j]=txt[j+1];max--;index--;txt[max]=NULL;
    }
    else txt[index]=' ';
   }
  }
  puts("€§¬Ґ­Ґ­­л© ⥪бв:");puts(txt);free(txt);getche();
  }
Соседние файлы в папке 2