求解释
  • 板块P1229 遍历问题
  • 楼主wy2013
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/11/24 10:16
  • 上次更新2024/11/24 11:48:47
查看原帖
求解释
955843
wy2013楼主2024/11/24 10:16

修改前代码不知道哪里冒出来一个NULL
修改完才好
谁来解释一下:\

#include<bits/stdc++.h>
using namespace std;
string s1,s2;
string dfs(string x1,string x2){
	if(x1.size()<2)
		return x1;
	char x=x2[0];
	string a[]={"",""};bool flag=true;
	for(int i=0;i<x1.size();i++){
		if(x1[i]==x){
			i++;flag=false;
		}
		if(flag){
			a[0]+=x1[i];
		}else{
			a[1]+=x1[i];
		}
	}
	string b[]={"",""};flag=true;
	for(int i=1;i<x2.size();i++){
		if(i==a[0].size()+1){
			flag=false;
		}
		if(flag){
			b[0]+=x2[i];
		}else{
			b[1]+=x2[i];
		}
	}
	return dfs(a[0],b[0])+dfs(a[1],b[1])+x;
}
int main(){
	cin>>s1;
	cin>>s2;
//修改后 
//	string s=dfs(s1,s2);
//	for(int i=0;i<s.size();i++){
//		if(s[i]!=NULL&&s[i]!=' ')cout<<s[i];
//	}
//修改前:
//	cout<<dfs(s1,s2); 
	return 0;
}
2024/11/24 10:16
加载中...