2 solutions

  • 0
    @ 2026-5-23 17:06:28
    //方法2
    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        string s1,s2,res="";
        cin>>s1>>s2;
        int b=s1.length();
        int a=b/2;
        for(int i=0;i<a;i++)
    		res+=s1[i];
        res+=s2;
        for(int i=a;i<b;i++) 
    		res+=s1[i];
        cout<<res;
        return 0;
    }
    
    • 0
      @ 2026-5-23 16:59:52
      //方法1
      #include <bits/stdc++.h>
      using namespace std;
      int main(){
          string s1,s2;
          cin>>s1>>s2;
          int b=s1.length();
          int a=b/2;
          for(int i=0;i<a;i++)
      		cout<<s1[i];
          cout<<s2;
          for(int i=a;i<b;i++) 
      		cout<<s1[i];
          cout<<endl;
          return 0;
      }
      
      • 1

      Information

      ID
      2042
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      10
      Tags
      (None)
      # Submissions
      6
      Accepted
      3
      Uploaded By