American Heritage

2023-12-15 15:58
文章标签 american heritage

本文主要是介绍American Heritage,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

刘汝佳小白书上有递归写法的源代码。

/*
ID:jinbo wu
LANG:C++
TASK:heritage
*/
#include<bits/stdc++.h>  
using namespace std;
void solve(int n,char *s1,char *s2,char *s)
{if(n<=0) return ;int p=strchr(s2,s1[0])-s2;solve(p,s1+1,s2,s);solve(n-p-1,s1+p+1,s2+p+1,s+p);s[n-1]=s1[0];}
int main()
{freopen("heritage.in","r",stdin);freopen("heritage.out","w",stdout);char s1[30];char s2[30];char ans[30];cin>>s1;cin>>s2;int n=strlen(s1);solve(n,s2,s1,ans);ans[n]='\0';cout<<ans<<endl;}
过几天数据结构考试没准要考这个顺便把后序,中序求先序也写出来。

#include<bits/stdc++.h>
using namespace std;
void build(int n,char *s1,char*s2,char*s)
{if(n<=0) return;int p=strchr(s2,s1[n-1])-s2;s[0]=s1[n-1];build(p,s1,s2,s+1);build(n-p-1,s1+p,s2+p+1,s+p+1);
}
int main()
{char s1[30],s2[30],ans[30];cin>>s1>>s2;build(strlen(s1),s1,s2,ans);ans[strlen(s1)]='\0';cout<<ans<<endl;}



这篇关于American Heritage的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/497016

相关文章

hdu(1178)Heritage from father

水题,主要考察了一个数学公式; #include<stdio.h> int main() {     int m,k;     double n;     while(scanf("%d",&m),m)     {         n=1.0*m*(m+1)*(m+2)/6.0;         k=0;         while(n>=10)

Coursera: An Introduction to American Law 学习笔记 Week 03: Property Law

An Introduction to American Law 本文是 https://www.coursera.org/programs/career-training-for-nevadans-k7yhc/learn/american-law 这门课的学习笔记。 文章目录 An Introduction to American LawInstructors Week 03: P

Coursera: An Introduction to American Law 学习笔记 Week 02: Contract Law

An Introduction to American Law 本文是 https://www.coursera.org/programs/career-training-for-nevadans-k7yhc/learn/american-law 这门课的学习笔记。 文章目录 An Introduction to American LawInstructors Week 02: C

【Scientific American】【科学美国人杂志】2024年4月号:前沿部分概览 Advances

说明: 仅供学习、参考使用,请勿用于商业用途。 本期购于新加坡,封面图: 了解最新的科技进展,欢迎关注博主。定期搬运【MIT Technology Review 麻省理工技术评论】【Scientific American 科学美国人】杂志内容。 Advances 【Conservation】Lost and Found Why are only some “lost” species

USACO-Section3.4 American Heritage【递归】

题目描述: 农夫约翰非常认真地对待他的奶牛们的血统。然而他不是一个真正优秀的记帐员。他把他的奶牛们的家谱作成二叉树,并且把二叉树以更线性的“树的中序遍历”和“树的前序遍历”的符号加以记录而不是用图形的方法。 你的任务是在被给予奶牛家谱的“树中序遍历”和“树前序遍历”的符号后,创建奶牛家谱的“树的后序遍历”的符号。每一头奶牛的姓名被译为一个唯一的字母。(你可能已经知道你可以在知道树的两种遍历以后

个人turtle小作品美队之盾(captain american's shield)

这周我通过我所观看的网课,学习到了一些turtle的绘图技巧,算是我这门课的一个入门小作品。我简单的画出了一个美国队长盾牌的图像。下面我来和大家分享一下: 上面呢就是我的作品,在绘图上面起初也遇到了很多的问题,首先是在五角星的绘图上面,要确定好各角角度(t.seth),并运用turtle.fd函数可以很有效地进行绘制,这个在难度上面较为简单,但程序编写上就显得比较复杂了。 然后在圆圈的绘制方面,

Is the American Dream Really Dead?

Our latest Freakonomics Radio episode is called “Is the American Dream Really Dead?” (You can subscribe to the podcast at iTunes or elsewhere, get the RSS feed, or listen via the media pla

嘭!美国金融巨头 First American 竟遭受黑客攻击

美国第二大保险公司 First American 面临严重的网络攻击 。对此,为了尽量减少此次事件的后果,部分公司系统被禁用,该公司的官方网站也暂时关闭。 First American 成立于 1889 年,专门为房地产行业提供金融和经纪服务。该公司年收入达 76 亿美元,拥有超过 21,000 名员工和数十万客户,是保险市场的重要参与者。 最近的一次是 11 月 28 日,第一美国公司因

嘭!美国金融巨头 First American 竟遭受黑客攻击

美国第二大保险公司 First American 面临严重的网络攻击 。对此,为了尽量减少此次事件的后果,部分公司系统被禁用,该公司的官方网站也暂时关闭。 First American 成立于 1889 年,专门为房地产行业提供金融和经纪服务。该公司年收入达 76 亿美元,拥有超过 21,000 名员工和数十万客户,是保险市场的重要参与者。 最近的一次是 11 月 28 日,第一美国公司因

Go American(Grandpa's Trunk 祖父的行李箱)

trunk KK: [ ] DJ: [ ] n.[C] 1. 树干 The trunk of this tree is four meters thick. 这棵树的树干有四米粗。 2. (旅行用)大皮箱;汽车车尾的行李箱 Let me put your baggage in the trunk. 我来把你的行李放在汽车后部的