| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 956 人关注过本帖
标题:错误提示sqrt没有定义,不知道怎么修改,请指教
取消只看楼主 加入收藏
jinafang3500
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2008-9-24
结帖率:100%
收藏
 问题点数:0 回复次数:1 
错误提示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);
}
搜索更多相关主题的帖子: include 1050 double 
2011-05-25 22:32
jinafang3500
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2008-9-24
收藏
得分:0 
回复 2楼 讀詠夅
咋了?怎么没人回答我,是我说的不清楚吗?
2011-05-25 23:14
快速回复:错误提示sqrt没有定义,不知道怎么修改,请指教
数据加载中...
 
   



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

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