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

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

.CPP
Скачиваний:
14
Добавлен:
28.03.2015
Размер:
639 б
Скачать
// ‘ ¬®Ґ ¤«Ё­­®Ґ б«®ў®
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <alloc.h>
# define ENTER 13
void main (void)
 {int n=80,i,j,begin,length=0;
  char ch,*txt=(char*)calloc(n,sizeof(char));
  clrscr();
  puts("ENTER-Є®­Ґж ўў®¤ ");
  for(i=0;(ch=getche())!=ENTER;i++)
    {if(i==n-1){n+=80;txt=(char*)realloc(txt,n*sizeof(char));}
    txt[i]=ch;
    if(ch==' ')
      {for(j=i;(txt[j-1]!=' ')&&(j>0);j--);
      if(i-j>length) {length=i-j;begin=j;}
      }
    }txt[i]=NULL;
  puts("\n‘ ¬®Ґ ¤«Ё­­®Ґ б«®ў®:");
  for(i=begin;i<length+begin;i++)
  printf("%c",txt[i]);
  free(txt);
  getche();
  }
Соседние файлы в папке 2