String Basics
Completed
Read a word. Print its length, first and last characters, and the word with ! appended.
Input
One word.
Output
Four lines.
Example
Input
hello
Output
5 h o hello!
Editor
C++
Hints
size() gives the length; back() the last character.
+ joins strings.
Solution explanation
std::string manages its own memory and supports +, == and <.
Show solution
#include <iostream>
#include <string>
using namespace std;
int main() {
string w;
cin >> w;
cout << w.size() << "\n" << w[0] << "\n" << w.back() << "\n" << w + "!" << "\n";
return 0;
}