-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5.cpp
45 lines (40 loc) · 937 Bytes
/
5.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Input Format
You are given two strings, a and b, separated by a new line. Each string will consist of lower case Latin characters ('a'-'z').
Output Format
In the first line print two space-separated integers, representing the length of and respectively.
In the second line print the string produced by concatenating and ().
In the third line print two strings separated by a space, and . and are the same as and , respectively, except that their first characters are swapped.
Sample Input:
abcd
ef
Sample Output:
4 2
abcdef
ebcd af
Explanation:
a = "abcd"
b = "ef"
|a| = 4
|b| = 2
a+b = "abcdef"
a' = "ebcd"
b' = "af"
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a , b;
cin>>a;
cin>>b;
cin.ignore(); // clears out the cin buffer
cout<<a.size() << " "<< b.size()<<endl;
cout<<a+b<<endl;
char temp;
temp = a[0];
a[0]=b[0];
b[0]=temp;
cout<<a<<" "<<b;
return 0;
}