-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.cpp
More file actions
28 lines (23 loc) · 1.12 KB
/
strings.cpp
File metadata and controls
28 lines (23 loc) · 1.12 KB
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
/*
Prompt: https://hackerrank-challenge-pdfs.s3.amazonaws.com/8044-c-tutorial-strings-English?response-content-disposition=inline%3B%20filename%3Dc-tutorial-strings-English.pdf&response-content-type=application%2Fpdf&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAR6O7GJNX5DNFO3PV%2F20250616%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250616T164548Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=7532f5bd5cef60ece122b8458c912d92a7f58eae8a038479b87c6a02069c4d2f
Submission: https://www.hackerrank.com/challenges/c-tutorial-strings/submissions/code/436133838
*/
#include <iostream>
#include <string>
using namespace std;
int main() {
// get inputs
string firstLine, secondLine;
getline(cin, firstLine);
getline(cin, secondLine);
// output size
cout << firstLine.size() << " " << secondLine.size() << endl;
// output concatination
cout << firstLine + secondLine << endl;
// swap first characters and output
char tempChar = firstLine[0];
firstLine[0] = secondLine[0];
secondLine[0] = tempChar;
cout << firstLine << " " << secondLine;
return 0;
}