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

帮忙啊。我的程序为什么总是WA啊!!!!!Thanks very much!!!

Posted by seachingdream at 2006-03-17 22:35:00 on Problem 1706
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int i,j,k,a,b=1,c,d,e,f,g,lenth;
char refer[3000][100]; 
char *t;
int number;
int mem[1000];
char pp;
int test;
char *p=&pp;
char *memory=&pp;
char *q=&pp;
int test2,test3=1;
int main()
{
	

	char ch[100];
	while (cin.getline(ch,81))
	{
		for (g=0;g<strlen(ch);g++)
		{
			if (ch[g]!=' ')
				break;
		}
		if (g==strlen(ch))
			ch[0]='\0';

		
		
		if (ch[0]!='\0')
			test=0;
		if (ch[0]=='\0'&&test)
			continue;
		if (ch[0]=='\0')
		{
			cout <<'\n';
			
			
			
			
			while (cin.getline(ch,81))
			{
				for (g=0;g<strlen(ch);g++)
				{
					if (ch[g]!=' ')
						break;
				}
				if (g==strlen(ch))
					ch[0]='\0';
				if (ch[0]!='\0')
				{
					test3=1;
					break;
				}
				else test3=0;
			}

		


		}
	
		 if (ch[0]=='[')
		{
			test=1;
				
			strcpy(refer[i],ch);
			i++;
			
			cin.getline(ch,81);
			for (g=0;g<strlen(ch);g++)
						{
							if (ch[g]!=' ')
								break;
						}
						if (g==strlen(ch))
						{
							ch[0]='\0';
							continue;
						}
			strcpy(refer[i],ch);
		
			if (refer[i][0]=='\0')
			{
			
				continue;
			}
			
			
			else 
			{
				i++;
				
				cin.getline(ch,81);
				for (g=0;g<strlen(ch);g++)
						{
							if (ch[g]!=' ')
								break;
						}
						if (g==strlen(ch))
						{

							ch[0]='\0';
							continue;
						}
				strcpy(refer[i],ch);
				
				if (refer[i][0]=='\0')
					{
						
				
						continue;
				
					}
				else i++;
			
			}
		
			continue;


		}

		else 
		{
			
			for (p=ch;*p!='\0';p++)
			{
				
				
				
				if (*p!='[')
				{
					cout <<*p;
					
				}
				else if (*p=='[')
				{
					cout <<*p;

					for (q=p,d=0;*q!=']';q++,d++);
					a++;
					for (c=1;c<d;c++)
					{
						mem[a]+=(*(p+c)-'0')*pow(10,d-c);
					}
					
					for (c=0;c<a;c++)
					{
						if (mem[c]==mem[a])
						{
							cout <<c<<']';
							for (;*p!=']';p++);
							test2=1;
							mem[a]=0;
							a--;
							break;
							
						}
					}
					if (!test2)
					{


						cout <<a<<']';
				
						p=q;
					}
					test2=0;
				}
				
			}
			if (test3)
			{
			
			cout <<endl;
			}
			for (e=0;e<100;e++)
				*(ch+e)='\0';
		}
	}
	if (!test&&test3)
	{
	cout <<endl;}
	
	
	for (f=1;mem[f]!=0;f++);

	for (i=0;refer[i][0]!='\0';i++)
	{
		for (g=0;g<strlen(refer[i]);g++)
						{
							if (refer[i][g]!=' ')
								break;
						}
						if (g==strlen(refer[i]))
							refer[i][0]='\0';
		if (refer[i][0]=='[')
		{
			p=&refer[i][0];
			
			for (q=p,d=0;*q!=']';q++,d++);
			for (c=1;c<d;c++)
					{
						number+=(*(p+c)-'0')*pow(10,d-c);
					}
			

			for (e=0;e<f;e++)
			{
				if (mem[e]==number)
				{
					
				
					*(p+1)=e+'0';
					number=0;
					break;
				}
			}
		}
	}

	for (e=1;e<f;e++)
	{
		
		for (i=0;refer[i][0]!='\0';i++)
		{
			
			if (refer[i][1]==e+'0')
			{
				
				t=strchr(refer[i],']');
				cout <<'['<<e<<t;
				cout <<endl;
				if (refer[i+1][0]!='['&&refer[i+1][0]!='\0')
				cout <<refer[i+1]<<endl;
				if (refer[i+2][0]!='['&&refer[i+2][0]!='\0')
				cout <<refer[i+2]<<endl;
			
				cout <<endl;
				
				break;
			}
			
		}
	}
	



		
		
		
		
		
	
	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