Strings

Sort by

recency

|

775 Discussions

|

  • + 0 comments
    int main() {
        string a, b;
        
        cin >> a >> b;
        
        cout << a.length() << " " << b.length() << endl;
        cout << a + b << endl;
        
        string a_(a), b_(b);
        
        a_[0] = b[0];
        b_[0] = a[0];
        
        cout << a_ << " " << b_ << endl;
        
        return 0;
    }
    
  • + 0 comments
    #include <iostream>
    #include <string>
    using namespace std;
    
    int main() {
    string a,b;
    cin>>a;
    cin>>b;
    cout<<a.length()<<" "<<b.length()<<endl;
    cout<<(a+b)<<endl;
    char temp;
    temp=a[0];
    a[0]=b[0];
    b[0]=temp;
    cout<<a<<" "<<b;
    
    return 0;
    

    }

  • + 0 comments

    Here is Strings problem solution in C++ - https://programmingoneonone.com/hackerrank-strings-solution-in-cpp.html

  • + 0 comments
    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;
    }
    
  • + 0 comments

    Great for beginners looking to grasp C++ string manipulation efficiently! betbricks 7