Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

再加上递归就更爽了,贴个非常短的

Posted by sbtdkj1017 at 2010-10-06 13:51:09 on Problem 1057
In Reply To:STL就是爽,把代码贴上来哈~~~~100题纪念~~~~ Posted by:yzhw at 2009-03-07 13:44:55
#include<iostream>
#include<string>
#include<list>
using namespace std;
string str;
void f(int layer, string dir)
{
	int i;
	list<string> fl;
	for(i=0;i<layer;i++)cout<<"|     ";
	cout<<dir<<endl;
	while(str!="]"&&str!="*")
	{
		if(str[0]=='f')fl.push_back(str);
		else dir=str,cin>>str,f(layer+1,dir);
		cin>>str;
	}
	fl.sort();
	for(list<string>::iterator it=fl.begin();it!=fl.end();it++)
	{
		for(i=0;i<layer;i++)cout<<"|     ";
		cout<<*it<<endl;
	}
}
int main()
{
	for(int t=1;cin>>str,str!="#";t++)
		cout<<"DATA SET "<<t<<':'<<endl,f(0,"ROOT"),cout<<endl;
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator