Strings

Sort by

recency

|

759 Discussions

|

  • + 0 comments

    include

    include

    using namespace std;

    int main() { string a="abcd"; string b="ef";

    cout<<a.length()<<" "<<b.length()<<endl;
    
    string temp=a+b;
    cout<<temp<<endl;
    
    swap(a[0],b[0]);
    cout<<a<<" "<<b;
    
    return 0;
    

    }

  • + 0 comments

    include

    include

    using namespace std;

    int main() { //string a="abcd"; //string b="ef"; string a; string b; cin>>a; cin>>b; cout<

    return 0;
    

    1. }

  • + 0 comments

    int main() { std::string a; std::string b; std::cin>>a; std::cin>>b;

    std::cout<<a.size()<<" "<<b.size()<<std::endl;
    std::cout<<a+b<<std::endl;
    
    std::string first_char_of_a = {a[0]};
    std::string second_char_of_b = {b[0]};
    
    std::cout<<a.replace(0,1, second_char_of_b)<<" "<<b.replace(0,1,first_char_of_a)<<std::endl;
    
    return 0;
    

    }

  • + 0 comments
    #include <iostream>
    #include <sstream>
    
    std::string getInput() {
        std::string inputt{};
        std::cin >> inputt;
        return inputt;
    }
    
    int main() {
       std::string first_val{getInput()};
       std::string second_val{getInput()};
       std::string first_char_of_first_value {first_val[0]};
       std::string second_char_of_first_value {second_val[0]};
       std::cout << first_val.length() << " " << second_val.length() << '\n';
       std::cout << first_val+second_val << '\n';
       std::cout << first_val.replace(0,1,second_char_of_first_value) << " " << second_val.replace(0,1,first_char_of_first_value) << '\n';
    
        return 0;
    }
    
  • + 1 comment

    include

    include

    using namespace std;

    int main() { // Complete the program string a,b; cin >> a; cin >> b;

    cout << a.size() << " " << b.size() << endl;
    cout << a + b << endl;
    
    char temp = b[0];
    b[0] = a[0];
    a[0] = temp;
    
    cout << a << " " << b << endl;
    return 0;
    

    }