Advertisement
hopingsteam

Untitled

May 11th, 2020
1,497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include    <iostream>
  2. #include    <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int inserari = 0;
  9.     char rezultat[101] = "";
  10.  
  11.     char text[101]; // testez validez utilizez date corecte acum
  12.     cin.getline(text, 101);
  13.  
  14.     char cuvPrec[101] = "";
  15.     char *cuvant = strtok(text, " ");
  16.     while(cuvant != NULL)
  17.     {
  18.         char uc1 = cuvant[strlen(cuvant) - 1];
  19.         char uc2 = cuvPrec[strlen(cuvPrec) - 1];
  20.         if(uc1 == uc2)
  21.         {
  22.             strcat(rezultat, "succes ");
  23.             inserari++;
  24.         }
  25.  
  26.         strcat(rezultat, cuvant);
  27.         strcat(rezultat, " ");
  28.  
  29.         strcpy(cuvPrec, cuvant);
  30.         cuvant = strtok(NULL, " ");
  31.     }
  32.  
  33.     if(inserari != 0)
  34.         cout << rezultat;
  35.     else
  36.         cout << "nu exista";
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement