Please Login in order to post a comment
int main() { // Complete the program string a , b , c; cin>>a>>b; cout<<a.length()<<" "<<b.length()<<endl; cout<<(a+b)<<endl; cout<<(b.substr(0,1)+a.substr(1,a.length()))<<" "<<(a.substr(0,1)+b.substr(1,b.length())); return 0; }
Great for beginners looking to grasp C++ string manipulation efficiently! betbricks 7
int main() { string a, b; getline(cin, a); getline(cin, b); std::cout << a.size() << " " << b.size() << std::endl; std::cout << a + b << std::endl; std::cout << b[0] + a.substr(1, a.npos) << " " << a[0] + b.substr(1, b.npos); return 0; }
string a, b; cin >> a >> b;
cout << a.size() << " " << b.size() << endl; cout << a + b << endl; char temp = a[0]; a[0] = b[0]; b[0] = temp; cout << a << " " << b << endl;
// Complete the program string a , b , c; cin>>a>>b; cout<<a.length()<<" "<<b.length()<<endl; cout<<a+b<<endl; swap(a[0],b[0]); cout<<a<<" "<<b<<endl; return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Great for beginners looking to grasp C++ string manipulation efficiently! betbricks 7
string a, b; cin >> a >> b;