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

跪求,一样代码poj G++,C++全部ac,然openjudge平台无限wa,求指点

Posted by 1500012708 at 2016-02-10 22:25:20 on Problem 1057
//1057 递归,不知为何poj ac然openjudge平台wa
#include <iostream>
#include <cstring>
using namespace std;
struct stru
{
	char name[100];
	int layer;	
}file[300];
const char prefix[10]="|     ";
int countfiles;
void showpre(int start,int layer)
{
	for(int i=1;i<=file[start].layer;++i) cout<<prefix;
	cout<<file[start].name<<endl;
	char sub[300][100]={'\0'};
	char *psub[300]={NULL};
	int marker=0;
	for(int i=start+1;i<=countfiles;++i)
	{
		if(file[i].layer<layer || (file[i].layer==layer && file[i].name[0]=='d')) 
		{
			marker=i-1;
			break;
		}
		if(i==countfiles) marker=countfiles;
	}
	for(int i=start+1;i<=marker;++i)
	{
		if(file[i].name[0]=='d' && file[i].layer==layer+1)
			showpre(i,layer+1);
	}
	int tempcount=0;
	for(int i=start+1;i<=marker;++i)
	{
		if(file[i].name[0]=='f' && file[i].layer==layer)
			strcpy(sub[tempcount++],file[i].name);
	}
	for(int i=0;i<tempcount;++i)
	{
		psub[i]=sub[i];
	}
	for(int i=0;i<tempcount;++i)
		for(int j=0;j<tempcount-1;++j)
			if(strcmp(psub[j],psub[j+1])==1)
			{
				char *temp=psub[j];
				psub[j]=psub[j+1];
				psub[j+1]=temp;
			}
	for(int i=0;i<tempcount;++i)
	{
		for(int j=1;j<=layer;++j)
			cout<<prefix;
		cout<<psub[i]<<endl;
	}
}
int main()
{
	int countcases=0;
	while(cin>>file[1].name)
	{
		if(!strcmp(file[1].name,"#")) break;
		else
		{
			++countcases;
			countfiles=1;
			file[0].name[0]='R';
			file[0].name[1]='O';
			file[0].name[2]='O';
			file[0].name[3]='T';
			file[0].name[4]='\0';
			file[0].layer=0;
			int curlayer=(file[1].name[0]=='d');
			file[1].layer=curlayer;
			while(cin>>file[++countfiles].name)
			{
				if(!strcmp(file[countfiles].name,"*"))
				{
					--countfiles;
					break;
				}
				else if(file[countfiles].name[0]=='d') ++curlayer;
				else if(file[countfiles].name[0]==']') 
				{
					--curlayer;
					--countfiles;
					continue;
				}
				file[countfiles].layer=curlayer;
			}
			if(countcases!=1) cout<<endl;
			cout<<"DATA SET "<<countcases<<':'<<endl;
			showpre(0,0);
			memset(file,0,sizeof(file));
		}
	}
	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