Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<stdio.h>
- #include<Windows.h>
- #include<string.h>
- int main()
- {
- char str[256], word[256],oneWord[30], inWord=0,maxWord=0,minWord=0, flag=0;
- int i, j, count = 0;
- while (printf("\n Enter text. For end - CTRL/Z: "), fgets(str, 255, stdin) != NULL)
- {
- inWord=0,maxWord=0,minWord=0, flag=0;
- i = 0, j = 0;
- for (i=0; str[i]; i++)
- {
- if (inWord == 0)
- {
- if (str[i] != ' ' && str[i] != '\t' &&str[i] != '\n')
- {
- word[j++] = str[i];
- inWord = 1;
- }
- }
- else
- {
- if (str[i] != ' ' && str[i] != '\t' &&str[i] != '\n')
- word[j++] = str[i];
- else
- {
- inWord = 0;
- word[j] = '\0';
- if (j > maxWord)
- {maxWord = j; }
- else
- if(j<maxWord && flag==0)
- { minWord = j;
- flag=1;
- }
- else
- if(j<minWord && flag==1)
- {
- minWord=j;
- }
- j = 0;
- printf("\n%s", word);
- count++;
- }
- }
- }
- printf("\n Max word is %d simbols, min word is %d simbols, number of all entered words is %d.\n", maxWord, minWord, count);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement