| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
如果递归的话,请问递归栈的最大程度大约是多少呢?/*
题目说最多15个string。如果递归的话,栈的大小也应该足够了
*/
#include <iostream>
#include <string>
using namespace std;
int N;
void do_it (int n) {
if (n == N / 2)
{
if (0 != N % 2) {
string str;
cin >> str;
cout << str << "\n";
}
return ;
}
string str1, str2;
cin >> str1 >> str2;
cout << str1 << "\n";
do_it(++n);
cout << str2 << "\n";
}
int main()
{
int set = 1;
while (cin >> N) {
if (0 == N)
break ;
cout << "SET " << (set++) << "\n";
do_it(0);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator