We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<iostream>#include<string>usingnamespacestd;intmain(){stringa,b;cin>>a>>b;// First line: lengths of a and bcout<<a.length()<<" "<<b.length()<<endl;// Second line: concatenated stringcout<<a+b<<endl;// Third line: swap first characters of a and bchartemp=a[0];a[0]=b[0];b[0]=temp;cout<<a<<" "<<b<<endl;return0;}
#include<cmath>#include<cstdio>#include<iostream>#include<string>usingnamespacestd;intmain(){// Assign strings a and bstringa;stringb;// Get the inputgetline(cin,a);getline(cin,b);// Find the lengthintlen1=a.size();intlen2=b.size();// Output length and concatenationcout<<len1<<" "<<len2<<endl;cout<<a+b<<endl;// Work on swapping the characterschartempChar=a[0];a[0]=b[0];b[0]=tempChar;// Output swapped characterscout<<a<<" "<<b;return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
include
using namespace std;
int main(){ string a,b; cin >> a >> b; cout << a.size() << " " << b.size() << endl; cout << a+b << endl; swap(a[0], b[0]); cout << a << " " << b << endl; return 0; }
include
include
using namespace std;
int main() { string a,b; cin>>a>>b; cout<
}
include
include
using namespace std;
int main() { // Complete the program string a , b ; cin>>a>>b; cout<
}
Here is my code, bit simple, easy to understand.