Advertisement
Nita_Cristian

Problema -5

Nov 19th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. /// Se da un sir de n cuvinte sa se determine cel mai lung cuvant
  2. #include<iostream>
  3. #include<cstring>
  4.  
  5. using namespace std;
  6.  
  7. char x[256];
  8.  
  9. int main()
  10. {
  11.     cin.getline(x, 256);
  12.  
  13.     int lungime_max = 0, lungime = 0;
  14.  
  15.     char *p = strtok(x, " ");
  16.  
  17.     while(p != NULL)
  18.     {
  19.         lungime = strlen(p);
  20.  
  21.         if(lungime > lungime_max)
  22.             lungime_max = lungime;
  23.  
  24.         p = strtok(NULL, " ");
  25.     }
  26.  
  27.     cout << lungime_max;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement