std::swap

Lab C++ Beginner 10 points

Read two words and two integers. Swap the words and the integers with std::swap and print them.

Input

Line 1: two words. Line 2: two integers.

Output

Two lines.

Example

Input

left right
1 2

Output

right left
2 1
Sample input available Sample output available
Editor
C++

Hints

std::swap works for any type.

Solution explanation

Library functions like swap are generic - one name works for strings, ints and more.

Show solution
#include <iostream>
#include <string>
#include <utility>
using namespace std;

int main() {
    string a, b;
    int x, y;
    cin >> a >> b >> x >> y;
    swap(a, b);
    swap(x, y);
    cout << a << " " << b << "\n" << x << " " << y << "\n";
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD