5 solutions

  • 8
    @ 2024-7-25 16:16:22

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int k;
        cin>>k;
        for(int i=1;i<=k;i++)
        {
            string s1;
            cin>>s1;
            int n=s1.size();
            for(int j=0;j<n;j+=2)
            {
                swap(s1[j],s1[j+1]);
            }
            cout<<s1<<endl;
        }
        return 0;
    }
    • 1
      @ 2026-6-13 14:31:17
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	int c;
      
      	cin>>c;
          for(int i=1;i<=c;i++){
      		string s1;
      		cin>>s1;
      		for(int i=0;i<=s1.size()-1;i+=2){
              	int temp=s1[i+1];
      			s1[i+1]=s1[i];
      			s1[i]=temp;
          	}
      		cout<<s1<<endl;
      	}
      
      	return 0;
      }
      
      
      • 0
        @ 2026-11-29 9:13:48
        
        #include<bits/stdc++.h>
        using namespace std;
        int main(){
        
        	string s;
            int n;
            cin>>n;
            for(int i=1;i<=n;i++){
                cin>>s;
                for(int j=0;j+1<s.size();j+=2){
                    swap(s[j],s[j+1]);
                }
                cout<<s<<endl;
            }
            
        	return 0;
        }
        
        • -2
          @ 2026-4-1 10:49:17

          #include <bits/stdc++.h> using namespace std; int main() { int k; cin>>k; for(int i=1;i<=k;i++) { string s1; cin>>s1; int n=s1.size(); for(int j=0;j<n;j+=2) { swap(s1[j],s1[j+1]); } cout<<s1<<endl; } return 0; }

          • -5
            @ 2024-7-24 16:17:45
            #include<bits/stdc++.h>
            using namespace std;
            int main(){
                 int t;
                 cin>>t;
                 while(t--){
                      string s;
                      cin>>s;
                      if(s.size()==1){
                           cout<<s<<endl;
                      }
                      else{
                           for(int i=0,j=1;i<s.size(),j<s.size();i+=2,j+=2){
                                swap(s[i],s[j]);
                           }
                           cout<<s<<endl;
                      }
                      
                 }
                 return 0;
            }
            
            • 1

            Information

            ID
            91
            Time
            1000ms
            Memory
            256MiB
            Difficulty
            1
            Tags
            (None)
            # Submissions
            89
            Accepted
            56
            Uploaded By