标题:[求助] C语言程序在VC++6.0中运行错在那里
取消只看楼主
ilvy8109
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-9-13
 问题点数:0 回复次数:0 
[求助] C语言程序在VC++6.0中运行错在那里

Compiling... 怎么修改啊 ?
aguss.c
7netn.c
7netn0.c
Linking...
7netn.obj : error LNK2005: _gaus already defined in aguss.obj
7netn0.obj : error LNK2005: _gaus already defined in aguss.obj
7netn0.obj : error LNK2005: _netn already defined in 7netn.obj
Debug/niu.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

以下是程序
//文件名7netn.c
#include "stdlib.h"
#include "math.h"
#include "stdio.h"
#include "aguss.c"
int netn(n,eps,t,h,x,k,f)
int n,k;
void (*f)();
double eps,t,h,x[];
{ int i,j,l;
double am,z,beta,d,*y,*a,*b;
y=malloc(n*sizeof(double));
a=malloc(n*n*sizeof(double));
b=malloc(n*sizeof(double));
l=k; am=1.0+eps;
while (am>=eps)
{ (*f)(x,b,n);
am=0.0;
for (i=0; i<=n-1; i++)
{ z=fabs(b[i]);
if (z>am) am=z;
}
if (am>=eps)
{ l=l-1;
if (l==0)
{ free(y); free(b); free(a);
printf("fail\n"); return(0);
}
for (j=0; j<=n-1; j++)
{ z=x[j]; x[j]=x[j]+h;
(*f)(x,y,n);
for (i=0; i<=n-1; i++) a[i*n+j]=y[i];
x[j]=z;
}
if (gaus(a,b,n)==0)
{ free(y); free(a); free(b); return(-1);}
beta=1.0;
for (i=0; i<=n-1; i++) beta=beta-b[i];
if (fabs(beta)+1.0==1.0)
{ free(y); free(a); free(b);
printf("fail\n"); return(-2);
}
d=h/beta;
for (i=0; i<=n-1; i++) x[i]=x[i]-d*b[i];
h=t*h;
}
}
free(y); free(a); free(b);
return(k-l);
}

#include "stdlib.h" //文件名 aguss.c
#include "math.h"
#include "stdio.h"
int gaus(a,b,n)
int n;
double a[],b[];
{ int *js,l,k,i,j,is,p,q;
double d,t;
js=malloc(n*sizeof(int));
l=1;
for (k=0;k<=n-2;k++)
{ d=0.0;
for (i=k;i<=n-1;i++)
for (j=k;j<=n-1;j++)
{ t=fabs(a[i*n+j]);
if (t>d) { d=t; js[k]=j; is=i;}
}
if (d+1.0==1.0) l=0;
else
{ if (js[k]!=k)
for (i=0;i<=n-1;i++)
{ p=i*n+k; q=i*n+js[k];
t=a[p]; a[p]=a[q]; a[q]=t;
}
if (is!=k)
{ for (j=k;j<=n-1;j++)
{ p=k*n+j; q=is*n+j;
t=a[p]; a[p]=a[q]; a[q]=t;
}
t=b[k]; b[k]=b[is]; b[is]=t;
}
}
if (l==0)
{ free(js); printf("fail\n");
return(0);
}
d=a[k*n+k];
for (j=k+1;j<=n-1;j++)
{ p=k*n+j; a[p]=a[p]/d;}
b[k]=b[k]/d;
for (i=k+1;i<=n-1;i++)
{ for (j=k+1;j<=n-1;j++)
{ p=i*n+j;
a[p]=a[p]-a[i*n+k]*a[k*n+j];
}
b[i]=b[i]-a[i*n+k]*b[k];
}
}
d=a[(n-1)*n+n-1];
if (fabs(d)+1.0==1.0)
{ free(js); printf("fail\n");
return(0);
}
b[n-1]=b[n-1]/d;
for (i=n-2;i>=0;i--)
{ t=0.0;
for (j=i+1;j<=n-1;j++)
t=t+a[i*n+j]*b[j];
b[i]=b[i]-t;
}
js[n-1]=n-1;
for (k=n-1;k>=0;k--)
if (js[k]!=k)
{ t=b[k]; b[k]=b[js[k]]; b[js[k]]=t;}
free(js);
return(1);
}

#include "stdio.h" //文件名 7netn0.c
#include "7netn.c"
main()
{ int i,k;
void netnf(double [],double [],int);
double eps,t,h;
static double x[3]={1.0,1.0,1.0};
t=0.1; h=0.1; eps=0.0000001; k=100;
i=netn(3,eps,t,h,x,k,netnf);
printf("\n");
printf("i=%d\n",i);
printf("\n");
for (i=0; i<=2; i++)
printf("x(%d)=%13.7e\n",i,x[i]);
printf("\n");
}

void netnf(x,y,n)
int n;
double x[],y[];
{ y[0]=x[0]*x[0]+x[1]*x[1]+x[2]*x[2]-1.0;
y[1]=2.0*x[0]*x[0]+x[1]*x[1]-4.0*x[2];
y[2]=3.0*x[0]*x[0]-4.0*x[1]+x[2]*x[2];
n=n;
return;
}


搜索更多相关主题的帖子: C语言 obj defined 
2007-09-14 18:46



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-169997-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.165158 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved