#include<stdio.h>
#include<wchar.h>
#include<locale.h>
#include<stdlib.h>
int main()
{
wchar_t wtext[512]={0},
minword[25]={0},maxword[25]={0},
*wpos, *filter=L",.:;!? ";
setlocale(LC_ALL, "Russian");
wprintf(L"Введите текст:\n");
fgetws(wtext, sizeof(wtext), stdin);
wtext[wcslen(wtext)-1]=L"\0";
wchar_t *word=wcstok(wtext, filter, &wpos);
wcscpy(minword, word);
wcscpy(maxword, word);
while(word!=NULL)
{
word=wcstok(NULL, filter, &wpos);
if(word==NULL) break;
if(wcslen(minword)>wcslen(word))
wcscpy(minword, word);
if(wcslen(maxword)<wcslen(word))
wcscpy(maxword, word);
}
wprintf(L"\nСамое длинное слово: %ls", maxword);
wprintf(L"\nСамое короткое слово: %ls", minword);
system("pause"); //пауза в Windows
return 0;
}
Текст, кроме слов, может содержать любые знаки препинания.
Найти самое длинное и самое короткое слово. Результат вывести на консоль. Самым коротким словом можно считать, в том числе, любой предлог или союз.