已知前序后序求中序的一种
function ok(s1,s2:string):boolean;
var i,l:integer; p:boolean;
第1题:
已知中序后序求前序
procedure Solve(mid,post:string);
var i:integer;
begin
if (mid='''') or (post='''') then exit;
i:=pos(post[length(post)],mid);
pre:=pre+post[length(post)]; {加上根,递归结束后pre即为前序遍历}
solve(copy(mid,1,I-1),copy(post,1,I-1));
solve(copy(mid,I+1,length(mid)-I),copy(post,I,length(post)-i));
end;
第2题:
试题30
若有定义语句: char *s1=”OK”, *s2=”ok”; , 以下选项中,能够输出”OK”的语句是()
A.if(strcmp(s1,s2)==0) puts(s1);
B.if(strcmp(s1,s2)!=0) puts(s2);
C.if(strcmp(s1,s2)==1) puts(s1);
D.if(strcmp(s1,s2)!=0) puts(s1);
第3题:
已知一棵树的中序遍历为DBGEACF,后序遍历为DGEBFCA,求这棵树的前序遍历。(字母和字母之间不要有空格) The infix order sequence of a tree is DBGEACF, and its post order sequence is DGEBFCA, please write down its preorder sequence. (There is no blank space between letters)
第4题:
若有定义语句:char *s1="OK",*s2="ok";,以下选项中,能够输出"OK"的语句是
A.if(strcmp(s1,s2)==0) puts(s1);
B.if(strcmp(s1,s2)!=0) puts(s2);
C.if(strcmp(s1,s2)==1) puts(s1);
D.if(strcmp(s1,s2)!=0) puts(s1);
第5题:
已知一棵树的前序遍历为ABDEGCF,中序遍历为DBGEACF,求这棵树的后序遍历。(字母和字母之间不要有空格) The preorder sequence of a tree is ABDEGCF, and its infix order sequence is DBGEACF, please write down its post order sequence. (There is no blank space between letters)