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

Re:我敢保证添的程序能在规定时间内算出结果,但是为什么频频遭遇presentation error,好心人能不能抽空看看运行一下我的程序,看看输出

Posted by tcxgsy at 2005-08-08 21:29:19 on Problem 1094
In Reply To:我敢保证添的程序能在规定时间内算出结果,但是为什么频频遭遇presentation error,好心人能不能抽空看看运行一下我的程序,看看输出 Posted by:ggg at 2004-05-19 08:18:57
>   
> 
> #include<iostream.h>
> #include<fstream.h>
> int relation[27][27];
> int zimu[27];
> char xulie[27];
> void print(int,int);
> void chushi(int);
> int main()
> {
> 	ifstream in;
> 	in.open("gao.txt");
> 	int a,b;
> 	int i;
> 	int j;
> 	char first,second,third;
> 	int ff,th;
> 	while(1)
> 	{
> 		
> 		cin>>a>>b;//a zimu,six given relations unknow true of false;
> 		if(a==0&&b==0)
> 			break;
> 		int num=0;//should be C(2,a) when completed totally;
> 		chushi(a);
> for(i=1;i<=b;i++)
> {
> 	cin>>first>>second>>third;
> 	ff=int(first)-int('A')+1;
> 	th=int(third)-int('A')+1;
> 	if(relation[ff][th]==1)
> 	{cout<<"Inconsistency found  after "<<i<<" relations."<<endl;
> 	goto la;}
> 	if(relation[ff][th]==0)
> 	{
> 	relation[ff][th]=-1;
> 	relation[th][ff]=1;
> 	num++;
> 	}
> 	for(j=1;j<=a;j++)
> 	{
> 		if(j!=ff&&j!=th)
> 		{
> 			if(!(relation[j][ff]==0&&relation[j][th]==0))
> 			{
> 				if(relation[j][ff]!=0&&relation[j][th]!=0)
> 				{
> 					if(relation[j][ff]==-1&&relation[j][th]==-1)
> 					{}
> 					else if(relation[j][ff]==1&&relation[j][th]==1)
> 					{}
> 					else if(relation[j][ff]==1&&relation[j][th]==-1)
> 					{}
> 					else
> 					{
> 						cout<<"Inconsistency found after "<<i<<" relations."<<endl;
> 						goto la;
> 					}
> 				}
> 				else if(relation[j][ff]==0)
> 				{if(relation[j][th]==1)
> 				{
>                  relation[j][ff]=1;
> 				 relation[ff][j]=-1;
> 				 num++;
> 				}
> 			 
> 				}
> 				else//relation[j][th]=0
> 				{
> 					if(relation[j][ff]==-1)
> 					{
> 						relation[j][th]=-1;
> 						relation[th][j]=1;
> 						num++;
> 					}
> 				}
> 				
> 			}
> 		}
> 	}
> if(num==a*(a-1)/2)
> {
> 	print(i,a);
> 	goto la;
> }
> }
> if(num<a*(a-1)/2)
> {
> 	cout<<"Sorted sequence cannot be determined."<<endl;
> }
> la: ;
> 	int k;
> 	char g,lao,feng;
> 	for(k=i+1;k<=b;k++)
> 		cin>>g>>lao>>feng;
> 	}
> 	return 0;
> }
> 
> void print(int h,int a)
> {
> cout<<"Sorted sequence determined after "<<h<<" relations: ";
> int i,j;
> for(i=1;i<=a;i++)
> {
> 	zimu[i]=0;
> }
> 
> for(i=1;i<=a;i++)
> for(j=1;j<=a;j++)
> {
> 	if(j!=i)
> 	{
>  if(relation[i][j]==1)
> 	 zimu[i]++;
> 	}
> }
> for(i=1;i<=a;i++)
> {
> xulie[zimu[i]+1]=char(i+int('A')-1);
> 
> }
> for(i=1;i<=a;i++)
> {
> cout<<xulie[i];
> }
> cout<<"."<<endl;
> }
> void chushi(int a)
> {
> 	int i;
> 	int j;
> 	for(i=1;i<=a;i++)
> 		for(j=1;j<=a;j++)
> 		{
> 			relation[i][j]=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