| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么总是错误,请高手帮忙,我是新手!谢谢!#include<iostream>
using namespace std;
#include<stdio.h>
void fs(int (*a)[101],int i,int *f,long &sum,int n);
void main()
{
int n;
int a[101][101];
while(scanf("%d",&n)!=EOF)
{
int i,j;
long sum=0,min;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
cin>>a[i][j];
int *f=new int[n];
for(j=0;j<n;j++)
f[j]=0;
fs(a,0,f,sum,n);
min=sum;
for(i=1;i<n;i++)
{
sum=0;
for(j=0;j<n;j++)
f[j]=0;
fs(a,i,f,sum,n);
if(min>sum)
min=sum;
}
cout<<min<<endl;
}
}
void fs(int (*a)[101],int i,int *f,long &sum,int n)
{
f[i]=1;
for(int j=0;j<n;j++)
{
if(f[j]==0)
{
sum+=a[i][j];
fs(a,j,f,sum,n);
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator