Advertisement
STANAANDREY

bac 4/20/2022 5

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