Advertisement
STANAANDREY

bac 4/19/2022 5

Apr 19th, 2022 (edited)
929
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4. char s[100], aux[100];
  5.  
  6. int main() {
  7.     gets(s);
  8.     char *p = strtok(s, " ");
  9.     bool ok = false;
  10.     while (p) {
  11.         if (strlen(p) % 2) {
  12.             strcat(aux, strrev(p));
  13.             ok = true;
  14.         } else {
  15.             strcat(aux, p);
  16.         }
  17.         strcat(aux, " ");
  18.         p = strtok(NULL, " ");
  19.     }
  20.     if (!ok) {
  21.         puts("nu exista");
  22.     } else {
  23.         aux[strlen(aux) - 1] = '\0';
  24.         strcpy(s, aux);
  25.         puts(s);
  26.     }
  27.     return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement