Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<conio.h>
- int main()
- {
- char Line[100];
- unsigned int i,count=0,TMP=0,MAX=0,MIN=9999,POS_MAX=0,POS_MIN=0,POS=0;
- printf("Введiть рядок: ");
- gets(Line);
- fflush(stdin);
- for(i=0;i<strlen(Line);i++)
- {
- if(Line[i]!=' ')
- count++;
- else
- {
- TMP=count;
- count=0;
- POS=i-TMP;
- if(TMP>MAX)
- {
- MAX=TMP;
- POS_MAX=POS;
- }
- if(TMP<MIN)
- {+
- MIN=TMP;
- POS_MIN=POS;
- }
- }
- }
- TMP=count;
- POS=i-TMP;
- if(TMP>MAX)
- {
- MAX=TMP;
- POS_MAX=POS;
- }
- if(TMP<MIN)
- {
- MIN=TMP;
- POS_MIN=POS;
- }
- printf("Кiлькiсть символiв у найдовшому словi: %i\nНомер початкової позицiї найдовшого слова: %i\nКiлькiсть символiв у найкоротшому словi: %i\nНомер початкової позицiї найкоротшого слова: %i",MAX,POS_MAX+1,MIN,POS_MIN+1);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement