Advertisement
hopingsteam

Untitled

May 5th, 2020
894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include    <iostream>
  2. #include    <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char text[101];
  9.     cin.getline(text,101);
  10.  
  11.     int cifraMax = -1;
  12.     int avemCifre = 0;
  13.  
  14.     int nr = 0;
  15.     char cMax = NULL;
  16.     char *cuvant = strtok(text, " ");
  17.     while(cuvant != NULL)
  18.     {
  19.         if(cuvant[0] >= '0' && cuvant[0] <= '9')
  20.         {
  21.             char c = cuvant[0];
  22.             if(c > cMax)
  23.             {
  24.                 nr = 0;
  25.                 cMax = c;
  26.                 for(int i = 0; i < strlen(cuvant); i++)
  27.                     nr = nr * 10 + cuvant[i] - '0';
  28.             }
  29.             avemCifre = 1;
  30.         }
  31.         cuvant = strtok(NULL, " ");
  32.     }
  33.     if(avemCifre == 1)
  34.         cout << nr;
  35.     else
  36.         cout << "nu exista";
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement