1 条题解

  • 0
    @ 2024-5-10 0:45:58

    C :

    #include<stdio.h>
    #include<string.h>
    
    int main()
    {
    	int n,i,j;
    	char a[50],b[50],c[100];
    	scanf("%d",&n);
    	while(n--)
    	{
    		scanf("%s%s",a,b);
    		for(i=0;i<strlen(a)/2;i++)
    			c[i]=a[i];
    		for(i=strlen(a)/2,j=0;j<strlen(b);i++,j++)
    			c[i]=b[j];
    		for(j=strlen(a)/2;a[j]!='\0';i++,j++)
    			c[i]=a[j];
    		c[i]='\0';
    		printf("%s\n",c);
    	}
    	return 0;
    }
    

    C++ :

    #include<stdio.h>
    #include<string.h>
    
    int main()
    {
    	int n,i,j;
    	char a[50],b[50],c[100];
    	scanf("%d",&n);
    	while(n--)
    	{
    		scanf("%s%s",a,b);
    		for(i=0;i<strlen(a)/2;i++)
    			c[i]=a[i];
    		for(i=strlen(a)/2,j=0;j<strlen(b);i++,j++)
    			c[i]=b[j];
    		for(j=strlen(a)/2;a[j]!='\0';i++,j++)
    			c[i]=a[j];
    		c[i]='\0';
    		printf("%s\n",c);
    	}
    	return 0;
    }
    

    Pascal :

    var t,k,i:longint;a,b:string;
    begin
     readln(t);
     for k:=1 to t do begin
      readln(a);
      readln(b);
      for i:=1 to length(a) div 2 do write(a[i]);
      write(b);
      for i:=length(a) div 2+1 to length(a) do write(a[i]);
      writeln;
     end;
    end. 
    

    Java :

    import java.util.Scanner;
    
    public class Main {
    
    	public static void main(String[] args) {
    		Scanner in = new Scanner(System.in);
    		int t = in.nextInt();
    		while(t-->0){
    			StringBuffer sb = new StringBuffer(in.next());
    			sb.insert(sb.length()/2, in.next());
    			System.out.println(sb);
    		}
    	}
    
    }
    
    

    Python :

    import sys
    l,k,t,r= 1,0,[],[]
    for line in sys.stdin:
        data = line.split()[0]
        if l !=1:
           k += 1
           if k%2 !=0:
              t = t+list(data)
           else:
              for j in range(len(t)/2):
                  r.append(t[j])
              r.append(data)
              for j in range(len(t)/2):
                  r.append(t[j+len(t)/2])
              print ''.join([i for i in r])
              k,t,r=0,[],[]
        l += 1
              
          
           
    

    C# :

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string str;
                int t=Convert.ToInt32(Console.ReadLine());
                while (t>0) 
                {
                    str = Console.ReadLine();
                    string str2 = Console.ReadLine();
                    str = str.Insert(str.Length/2,str2);
                    Console.WriteLine(str);
                    t--;
                }
            }
        }
    }
    
    
    
    
    
    
    • 1

    信息

    ID
    6231
    时间
    1000ms
    内存
    32MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者