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

【help】在本机上运行结果格式都正确,提交总是结果错误或run error,请帮忙看看

Posted by xls at 2007-02-28 19:06:57 on Problem 2240
#include <iostream.h>
#include <string.h>
#define BIG 50
int main()
{
int i,j,u,v,k,n,t=0;//t为数据组数,n为货币种数
int exist[BIG];
for(i=0;i<BIG;i++)
	exist[i]=0;
cin>>n;
while(n)
{
t++;
float * *c;
c=new float*[n];
for(i=0;i<n;i++)
   c[i]=new float[n];
for(i=0;i<n;i++)
	for(j=0;j<n;j++)
		if(i==j) c[i][j]=1;
		else c[i][j]=0;
//输入一组数据
char * *currency;
currency=new char*[n];
for(i=0;i<n;i++)
{   currency[i]=new char[BIG];
    cin>>currency[i];
}
int m,a,b;
cin>>m;
char acurrency[BIG],bcurrency[BIG];
float rate;
for(i=0;i<m;i++)
{  cin>>acurrency>>rate>>bcurrency;
   for(j=0;j<n;j++)
	   if (!strcmp(acurrency,currency[j]))
		   a=j;
	   else if (!strcmp(bcurrency,currency[j]))
		   b=j;
	c[a][b]=rate;
}
cout<<endl;         
//计算主体         
for( k=0;k<n;k++)
   for(u=0;u<n;u++)
      for(v=0;v<n;v++)
         if (c[u][v]<c[u][k]*c[k][v])
            c[u][v]=c[u][k]*c[k][v];
for( u=0;u<n;u++)
      if (c[u][u]>1)
      {  exist[t]=1;
         break;
      }

//空间释放
for(i=0;i<n;i++)
{	delete [] c[i];
	delete [] currency[i];
}
delete [] c;
delete  [] currency;
//输出结果 

cin>>n;
}
i=1;
while(i<=t)
{
	if (exist[i])
	cout<<"case"<<' '<<i<<':'<<"yes"<<endl;
	else
    cout<<"case"<<' '<<i<<':'<<"no"<<endl;
	i++;
}
    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