错误提示sqrt没有定义,不知道怎么修改,请指教
#include <stdio.h>#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
char comments[256];
int i, j;
double J=0.0, dx=0.0, dv=0.0;
double load1=0.0, load2=0.0, load3=0.0, load4=0.0;
double *coord, *coord0, *coord1, *velocity, *velocity0, *velocity1;
coord = (double *)malloc(1050*sizeof(double));
coord0 = (double *)malloc(1050*sizeof(double));
coord1 = (double *)malloc(1050*sizeof(double));
velocity = (double *)malloc(1050*sizeof(double));
velocity0 = (double *)malloc(1050*sizeof(double));
velocity1 = (double *)malloc(1050*sizeof(double));
FILE *pp1, *pp2;
pp1=fopen("1129-5000.velS", "r");
pp2=fopen("pengzhuanghousudu.dat", "w");
for( i=0; i<1050; ++i ){
fscanf(pp1, "%lf %lf %lf %lf", &load1, &load2, &load3, &load4);
coord0[i]=load1;
coord1[i]=load2;
coord[i]=sqrt(coord0[i]*coord0[i]+coord1[i]*coord1[i]);
velocity0[i]=load3;
velocity1[i]=load4;
velocity[i]=sqrt(velocity0[i]*velocity0[i]+velocity1[i]*velocity1[i]);
}
for(i=0;i<1050-1;++i){
for(j=i+1;j<1050;++j){
dx=coord[j]-coord[i];
dv=velocity[j]-velocity[i];
J=-1.9*2650.0*2650.0/(2650.0+2650.0)*dv+0.4*1.9*2650.0*2650.0/(2650.0+2650.0)*dv;
if(dx<0.00015){
velocity0[i]+=J/2650.0;
velocity1[i]+=J/2650.0;
velocity0[j]-=J/2650.0;
velocity1[j]-=J/2650.0;
}
}
}
coord0[i]=velocity0[i]*0.000005;
coord1[i]=velocity1[i]*0.000005;
coord0[j]=velocity0[j]*0.000005;
coord1[j]=velocity0[j]*0.000005;
strcpy( comments, "TITLE = \"velocity of sand\"" ); fprintf(pp2, "%s\n", comments);
strcpy( comments, "VARIABLES = \"X\",\"Y\",\"x-velocity\", \"y-velocity\"" );fprintf(pp2, "%s\n", comments);
strcpy( comments, "ZONE I=105,J=10,F=point\n" ); fprintf(pp2, "%s", comments);
for(i=0;i<1050;i++){
fprintf(pp2, "%e %e %e %e\n", coord0[i], coord1[i], velocity0[i], velocity1[i]);
}
fclose(pp1);
fclose(pp2);
}