Advertisement
bogdanNiculeasa

Inversa nume prenume si folosire initiala

Dec 7th, 2022
751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 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.  
  13.     // s contine Popescu      Vasile
  14.     strcpy(result, strrchr(s, ' ')+1);
  15.     result[1] = '\0';
  16.     strcat(result, ". ");
  17.     strcat(result, strtok(s, " "));
  18.  
  19.     cout << result;
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement