Advertisement
STANAANDREY

tema dragos pb3

Jan 5th, 2022
998
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. void solve(char *s) {
  6.     char aux[102] = {};
  7.     char arr[102][102] = {};
  8.     int arrLen = 0;
  9.  
  10.     {
  11.         char *p = strtok(s, " ");
  12.         while (p) {
  13.             strcpy(arr[arrLen++], p);
  14.             p = strtok(NULL, " ");
  15.         }
  16.     }
  17.  
  18.     strcat(aux, arr[0]);
  19.     strcat(aux, " ");
  20.     for (int i = 1; i < arrLen; i++) {
  21.         int n1 = strlen(arr[i - 1]), n2 = strlen(arr[i]);
  22.         if (arr[i - 1][n1 - 1] == arr[i][n2 - 1]) {
  23.             strcat(aux, "succes");
  24.             strcat(aux, " ");
  25.         }
  26.         strcat(aux, arr[i]);
  27.         strcat(aux, " ");
  28.     }//*/
  29.    strcpy(s, aux);
  30. }
  31.  
  32. int main() {
  33.     char s[102];
  34.     gets(s);
  35.     solve(s);
  36.     puts(s);
  37.     return 0;
  38. }
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement