Advertisement
Spocoman

06. Concatenate Data

Aug 22nd, 2024
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6.     string firstName, lastName;
  7.     cin >> firstName >> lastName;
  8.  
  9.     int age;
  10.     cin >> age;
  11.     cin.ignore();
  12.  
  13.     string town;
  14.     getline(cin, town);
  15.  
  16.     cout << "You are " << firstName << ' ' << lastName << ", a " << age << "-years old person from " << town << '.' << endl;
  17.  
  18.     return 0;
  19. }
  20.  
  21. ИЛИ:
  22.  
  23. #include <iostream>
  24. #include <string>
  25. using namespace std;
  26.  
  27. int main() {
  28.     string firstName, lastName;
  29.     cin >> firstName >> lastName;
  30.  
  31.     int age;
  32.     cin >> age;
  33.     cin.ignore();
  34.  
  35.     string town;
  36.     getline(cin, town);
  37.  
  38.     printf("You are %s %s, a %i-years old person from %s.", firstName.c_str(), lastName.c_str(), age, town.c_str());
  39.  
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement