Strings

Sort by

recency

|

774 Discussions

|

  • + 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

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