bogdanNiculeasa

Inversare nume prenume v2

Dec 7th, 2022
823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6.  
  7.  
  8. int main() {
  9.     char s[21];
  10.     char result[21];
  11.     cin.getline(s, 21);
  12.     // s contine Popescu      Vasile
  13.     strcpy(result, strrchr(s, ' ')+1);
  14.     strcat(result, " ");
  15.     strcat(result, strtok(s, " "));
  16.  
  17.     cout << result;
  18.  
  19.  
  20.     return 0;
  21. }
  22.  
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment