Advertisement
madidino

teza6-sub3-1

Nov 12th, 2023 (edited)
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. //void var_mat()
  5. //{
  6. //    char s[100];
  7. //    cin.getline(s,100);
  8. //    char cuv[100][100];
  9. //    int k=0;
  10. //    char *p=strtok(s," ");
  11. //    while(p)
  12. //    {
  13. //        strcpy(cuv[k],p);
  14. //        k++;
  15. //        p=strtok(NULL," ");
  16. //    }
  17. //}
  18. //void citire_prop_cand_stim_nr()
  19. //{
  20. //    char s[100];
  21. ////    while(cin.getline(s,100))
  22. //    {
  23. //        blabla
  24. //    }
  25. //}
  26. //void citire_prop_cand_stim_nr()
  27. //{
  28. //    char s[100];
  29. //    int n;
  30. //    cin>>n;
  31. //    cin.ignore();//sa nu ia enter ul de dupa nr de prop
  32. //    //la fisier nu e nevoie
  33. //    for(int i=1; i<=n; i++)
  34. //    {
  35. //        cin.getline(s,100);
  36. //    }
  37. //}
  38. int main()
  39. {
  40.     char s[100];
  41.     cin.getline(s,100);
  42.     int mx=-1;
  43.     int k=0;
  44.     int lng;
  45.     char *p;
  46.     p=strtok(s," ");
  47.     while(p)
  48.     {
  49.         lng=strlen(p);
  50.         if(mx<lng)
  51.         {
  52.             mx=lng;
  53.             k=1;
  54.         }
  55.         else
  56.         {
  57.             if(mx==lng)
  58.             {
  59.                 k++;
  60.             }
  61.         }
  62.         p=strtok(NULL," ");
  63.     }
  64.     cout<<mx<<" "<<k<<".";
  65.         return 0;
  66. }
  67. //eu dau bacalaureat la informatica
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement