Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<conio.h>
  4.  
  5. int main()
  6. {
  7. char Line[100];
  8. unsigned int i,count=0,TMP=0,MAX=0,MIN=9999,POS_MAX=0,POS_MIN=0,POS=0;
  9. printf("Введiть рядок: ");
  10. gets(Line);
  11. fflush(stdin);
  12. for(i=0;i<strlen(Line);i++)
  13. {
  14. if(Line[i]!=' ')
  15. count++;
  16. else
  17. {
  18. TMP=count;
  19. count=0;
  20. POS=i-TMP;
  21. if(TMP>MAX)
  22. {
  23. MAX=TMP;
  24. POS_MAX=POS;
  25. }
  26. if(TMP<MIN)
  27. {+
  28. MIN=TMP;
  29. POS_MIN=POS;
  30. }
  31. }
  32. }
  33. TMP=count;
  34. POS=i-TMP;
  35. if(TMP>MAX)
  36. {
  37. MAX=TMP;
  38. POS_MAX=POS;
  39. }
  40. if(TMP<MIN)
  41. {
  42. MIN=TMP;
  43. POS_MIN=POS;
  44. }
  45. 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);
  46. getch();
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement