Problem Description
Kong belongs to a huge family. Recently he got a family name list which lists all men (no women) in his family over many generations.

The list shows that the whole family has a common ancestor, let's call him Mr. X. Of course, everybody except Mr.X in the list is Mr. X's descendant. Everybody's father is shown in the list except that Mr. X's father is not recorded. We define that Mr. X's generation number is 0. His son's generation number is 1.His grandson's generation number is 2, and so on. In a word, everybody's generation number is 1 smaller than his son's generation number. Everybody's generation number is marked in some way in the list.

Now Kong is willing to pay a lot of money for a program which can re-arrange the list as he requires ,and answer his questions such as how many brothers does a certain man have, etc. Please write this program for him.

Input
There are no more than 15 test cases.
For each test case:
The first line is an integer N( 1 <= N <= 30,000), indicating the number of names in the list.
The second line is the name of Mr. X.
In the next N-1 lines, there is a man's name in each line. And if the man's generation number is K, there are K dots( '.') before his name.

1) A name consists of only letters or digits( '0'-'9').
2) All names are unique.
3) Every line's length is no more than 60 characters.
4) In the list, a man M's father is the closest one above M whose generation number is 1 less than M.
5) For any 2 adjacent lines in the list, if the above line's generation number is G1 and the lower line' s generation number is G2, than G2 <= G1 +1 is guaranteed.

After the name list, a line containing an integer Q(1<=Q<=30,000) follows, meaning that there are Q queries or operations below.

In the Next Q lines, each line indicates a query or operation. It can be in the following 3 formats:
1) L
Print the family list in the same format as the input, but in a sorted way. The sorted way means that: if A and B are brothers(cousins don’t count), and A's name is alphabetically smaller than B's name, then A must appear earlier than B.
2) b name
Print out how many brothers does "name" have, including "name" himself.
3) c name1 name2
Print out the closest common ancestor of "name1" and "name2". "Closest" means the generation number is the largest. Since Mr. X has no ancestor in the list, so it's guaranteed that there is no question asking about Mr. X's ancestor.

The input ends with N = 0.

Output

Sample Input
9
Kongs
.son1
..son1son2
..son1son1
...sonkson2son1
...son1son2son2
..son1son3
...son1son3son1
.son0

7
L
b son1son3son1
b son1son2
b sonkson2son1
b son1
c sonkson2son1 son1son2son2
c son1son3son1 son1son2
0

Sample Output
Kongs
.son0
.son1
..son1son1
...son1son2son2
...sonkson2son1
..son1son2
..son1son3
...son1son3son1
1
3
2
2
son1son1
son1

#include<iostream> using namespace std; void hanoi(int n,char a,char b,char c) { if(n==1) cout<<n<<" "<<a<<"->"<<c<<endl; else{ hanoi(n-1,a,c,b); cout<<n<<" "<<a<<"->"<<c<<endl;//指这条代码 hanoi(n-1,b,a,c); } } int main() { int n; while(cin>>n) hanoi(n,'A','B','C'); return 0; } 请问为什么那条cout输出语句（代码中注释部分）为什么在中间 而不是在hanoi(n-1,b,a,c);后面或者有两个语句后面都cout。 谢谢~

java List递归组合问题 最后输出结果不一样

javascript中递归实现1+2+3+4+...+100怎么实现，js递归输出结果可以用log

javascript中递归实现1+2+3+4+...+100怎么实现，js递归输出结果可以用log 这里的递归是编写函数么？还是用什么办法，写了几个都不行，求助

{"data"=>[{"id"=>122, "parentId"=>0, "name"=>" 桌子凳子", "description"=>"AA", "image"=>"", "order"=>0, "extraData"=>nil, "subCategories"=>[{"id"=>123, "parentId"=>122, "name"=>"电脑桌", "description"=>"1903", "image"=>"", "order"=>0, "extraData"=>nil, "subCategories"=>[{"id"=>568, "parentId"=>123, "name"=>"儿童桌子", "description"=>"6416", "image"=>"", "order"=>0, "extraData"=>nil, "subCategories"=>[]}]}, {"id"=>512, "parentId"=>122, "name"=>"儿童桌子", "description"=>"6416", "image"=>"", "order"=>0, "extraData"=>nil, "subCategories"=>[]}]}], "count"=>1}

java list 内递归构建树，效率很差，如果remove节点报ConcurrentModificationException

C语言的递归输出，会输出重复的打印信息，不知道是不是跟输出流缓冲有关

C：用递归及非递归解决迷宫问题

![图片说明](https://img-ask.csdn.net/upload/201611/09/1478653074_231913.png) ``` #include<stdio.h> //约瑟夫问题，共n个人，从x开始数数，数到y时去掉，要求最后剩下的一个人编号为1 typedef int elemtype; typedef struct{ elemtype data; struct Node *next; }*Linklist,Node; int f(Node *start,int n,int y,Linklist L) //递归算法 { Node *s,*p; elemtype e; int i; if (n==1&&start->data==1) return 1; //若最后剩下1，则返回1 if (n==1) {printf("%d\n",start->data);return 0;} //其他则输出最后的编号，并返回0 for (i=1,p=start;i<y-1;i++) // 删除数到y的 { p=p->next; } s=p->next; e=s->data; p->next=s->next; free(s); printf("%d\t",e); //输出删除的编号 start=p->next; f(start,n-1,y,L); } void TraverseList(Linklist L) { Node *p=L; while(p->data!=5) { printf("%d\t",p->data); p=p->next; } printf("\n"); } int main() { Linklist L; L=(Linklist)malloc(sizeof(Node)); Node *start,*p,*s; int y,n,x,i,c; printf("请输入总人数：\n"); scanf("%d",&n); L->data=1; //编号 L->next=NULL; p=L; for (i=2;i<=n;i++) { s=(Node*)malloc(sizeof(Node)); s->data=i; s->next=p->next; p->next=s; p=p->next; } p->next=L; //围圈 TraverseList(L); for (x=1;x<2;x++) //先固定x只能为1 { for (i=1,p=L;i<x;i++) p=p->next; start=p; for(y=2;y<n;y++) //y可从2~n-1变化 { if (f(start,n,y,L)==1) printf("x:%d\t y:%d\n",x,y); //如果返回值为1，说明最后剩下了1，输出x，y的值 Linklist L; //由于前面删除了链表，所以重新建立单循环链表 L=(Linklist)malloc(sizeof(Node)); L->data=1; L->next=NULL; p=L; for (i=2;i<=n;i++) { s=(Node*)malloc(sizeof(Node)); s->data=i; s->next=p->next; p->next=s; p=p->next; } p->next=L; TraverseList(L); } } getch(); return 0; } ```

java list组合递归问题 结果显示有重复的数据 怎么去掉啊 不知道哪里写错了

C语言怎么用递归输出2的64次方

C++用递归方式输出100以内的质数

2020阿里全球数学大赛：3万名高手、4道题、2天2夜未交卷

HashMap底层实现原理，红黑树，B+树，B树的结构原理 Spring的AOP和IOC是什么？它们常见的使用场景有哪些？Spring事务，事务的属性，传播行为，数据库隔离级别 Spring和SpringMVC，MyBatis以及SpringBoot的注解分别有哪些？SpringMVC的工作原理，SpringBoot框架的优点，MyBatis框架的优点 SpringCould组件有哪些，他们...

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版（进大厂必备）

《Oracle Java SE编程自学与面试指南》最佳学习路线图（2020最新版）