Advertisement
crzhel

Untitled

Apr 18th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. cout << "Write your sentence: ";
  8. char str[100];
  9. cin.getline(str, 100);
  10.  
  11. int lenstr = 0, lenword = 0, i, j, maxS = 0, id = 0;
  12.  
  13. for(lenstr = 0;str[lenstr] != '\0';lenstr++){
  14.  
  15. }
  16. int space = 0;
  17.  
  18. for(i = 0;i < lenstr;i++){
  19. if (str[i] >= 'A' && str[i] <= 'z'){
  20. lenword++;
  21. }else if (lenword > maxS){
  22. maxS = lenword - space;
  23. id = i - maxS;
  24. lenword = 0;
  25. space = 0;
  26. }
  27.  
  28. if (i == lenstr-1 && str[i] >= 'A' && str[i] <= 'z'){
  29. cout << "+" << endl;
  30. if (lenword > maxS){
  31. maxS = lenword - space;
  32. id = i - maxS + 1;
  33. lenword = 0;
  34. space = 0;
  35. cout << "++";
  36. }
  37. }
  38.  
  39. for(j = 32;j < 64;j++){
  40. if(str[i] == char(j)){
  41. space++;
  42. }
  43. }
  44.  
  45. }
  46. cout << endl;
  47. for(i=0;i < maxS;i++){
  48. cout << str[id];
  49. id++;
  50. }
  51.  
  52. cout << endl << "Length stroke: " << lenstr << endl << "Maxs letter in word: " << maxS << endl << "id:" << id << endl <<"lenword: " << lenword << endl ;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement