题目链接
#include<iostream>
#include<string>
using namespace std;
int main() {
int n;
cin >> n;
getchar(); // 吸收n后的一个回车
while (n--) {
string s, t;
cin >> s >> t;
string result = "";
for (int i = 0; i < s.size() / 2; i++) { // 处理s的前半段
result += s[i];
}
result += t; // 添加 字符串t
for (int i = s.size() / 2; i < s.size(); i++) { // 处理s的后半段
result += s[i];
}
cout << result << endl;
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String str = null;
while((str = reader.readLine())!= null){
StringTokenizer tokenizer = new StringTokenizer(str);
int n = Integer.parseInt(tokenizer.nextToken());
for(int i = 0; i < n; i++){
String a = reader.readLine();
String b = reader.readLine();
StringBuilder sb = new StringBuilder();
int len = a.length();
sb.append(a.substring(0,len/2));
sb.append(b);
sb.append(a.substring(len/2,len));
System.out.println(sb.toString());
}
}
}
}
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
for (int i = 0; i < n; i++) {
String a = in.next();
String b = in.next();
StringBuilder sb = new StringBuilder(a);
sb.insert(a.length() / 2, b);
System.out.println(sb.toString());
}
}
}
n = int(input())
for _ in range(n):
line1 = input()
line2 = input()
mid = len(line1) // 2
result = line1[:mid] + line2 + line1[mid:]
print(result)
package main
import "fmt"
func main() {
var n int
_, err := fmt.Scan(&n)
if err != nil {
return
}
for n > 0 {
var a, b string
_, _ = fmt.Scanln(&a)
_, _ = fmt.Scanln(&b)
fmt.Println(a[:len(a)/2] + b + a[len(a)/2:])
n--
}
}
const rl=require("readline").createInterface({input:process.stdin});
const iter=rl[Symbol.asyncIterator]();
const readline=async ()=>(await iter.next()).value;
function merge(str1,str2){
const middle=Math.floor(str1.length/2);
return str1.slice(0,middle)+str2+str1.slice(middle);
}
async function main(){
const n=parseInt(await readline());
for(let i=0;i<n;i++){
let str1=await readline();
let str2=await readline();
console.log(merge(str1,str2));
}
}
main();
#include <stdio.h>
#include <string.h>
int main() {
int n;
char tmp;
scanf("%d", &n);
char s[100], t[100];
fgets(s, sizeof(s), stdin); // 吸收换行符
while (n--) {
fgets(s, sizeof(s), stdin); // 读取s字符串
s[strcspn(s, "\n")] = '\0'; // 移除换行符
fgets(t, sizeof(t), stdin); // 读取t字符串
t[strcspn(t, "\n")] = '\0'; // 移除换行符
char result[200] = "";
int len = strlen(s);
int mid = len % 2 == 0 ? len / 2 : len / 2 + 1;
strncpy(result, s, mid); // 复制s的前半部分到result
strcat(result, t); // 连接字符串t到result
strcat(result, s + mid); // 连接s的后半部分到result
printf("%s\n", result);
}
return 0;
}