Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- char str[256];
- char str2[256];
- char word[256];
- char str3[256];
- int inWord = 0,count=0;
- int maxLen = 0 ,minLen=256;
- while (fgets(str, 255, stdin) != NULL)
- {
- int j = 0;
- for (int i = 0; str[i]; i++)
- {
- if (inWord == 0)
- {
- if (str[i] != ' ' && str[i] != '\n' && str[i] != '\t')
- {
- inWord = 1;
- if (strlen(str) > maxLen)
- {
- maxLen = strlen(str);
- strcpy(str2, str);
- }
- if (strlen(str) < minLen)
- {
- minLen = strlen(str);
- strcpy(str3, str);
- }
- word[j++] = str[i];
- }
- }
- else
- {
- if (str[i] != ' ' && str[i] != '\n' && str[i] != '\t')
- {
- word[j++] = str[i];
- if (strlen(str) > maxLen)
- {
- printf("word with max length changed\n");
- maxLen = strlen(str);
- strcpy(str2, str);
- }
- if (strlen(str) < minLen)
- {
- printf("word with min length changed\n");
- minLen = strlen(str);
- strcpy(str3, str);
- }
- }
- else
- {
- inWord = 0;
- word[j] = '\0';
- j = 0;
- count++;
- }
- }
- }
- printf("Word:%s\n", word);
- printf("Max Length word:%s", str2);
- printf("Min Length word:%s", str3);
- printf("Word Count:%d\n", count);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement