Advertisement
Guest User

stroke 2

a guest
Jan 24th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     char str[256]="";
  8.     int i;
  9.     int d;
  10.     for(i=0;i<256;i++)
  11.     {
  12.         if(str[i]!=' ')
  13.         {
  14.             d++;
  15.         }
  16.     }
  17.     cout << "Wwedi stroku :";
  18.     cin.getline (str,256);
  19.     int now=0, max=0,id;
  20.     for(i=0;i<d;i++)
  21.     {
  22.         if(str[i]>='A'&&str[i]<='z')
  23.           {
  24.             now=now+1;
  25.           }
  26.           else
  27.           {
  28.               if (now>max)
  29.               {
  30.                 max=now;
  31.                 id=i-now;
  32.               }
  33.               now=0;
  34.           }
  35.     }
  36.     cout << "Dlina slova : " <<max << endl;
  37.     cout << "Slovo : ";
  38.     max=max+id;
  39.     for(;id<max;id++)
  40.     {
  41.         cout << str[id];
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement