| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 479 人关注过本帖
标题:[求助]紧急求助~!!
只看楼主 加入收藏
yf0sky
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-6-29
收藏
 问题点数:0 回复次数:0 
[求助]紧急求助~!!

tc总是说:floating point error:domain 请各位高手帮忙看下,明天下午就要交拉~!!!!55555555555555~!! #include <conio.h> /* 此头函数请不要删除 */ #include<stdio.h> #include<math.h> #define inf 32767.00/*wuqiongda panding*/ #define n 9/*N biaoshi jiedian shu*/ void shortestpath(int begin,int terminal); void distribution(int n1,int n2); void check(); void shuchu(); int snode[12];

/*system chushihua*/ int v[n][n], v1[n][n]; double t[n][n],t0[n][n],t1[n][n]; /*V shi cunfang diyici fenpei de liuliang shuzu*/ /*v1 shi cunfang diedai hou de liuliang shuzu*/ /*t shi diyici de luquan shuzu*/ /*t0 shi lingliu shi de luquan shuzu*/ /*t1 shi diedai hou de luquan shuzu*/ int DS[n][n]; int OD[4][4]={{0,200,200,500},{200,0,500,100},{200,500,0,250},{500,100,250,0}}; int i,j; int v0;/*v0 shi shejichesu*/ int jiedian[4]={1,3,7,9}; /*shi jiedian A,B,C,D de shuzu*/ int flag,flag1,flag2;/*flag shi kongzhi quanju xunhuan de tag*/ /*flag1 shi kongzhi liuliang jingdu de xunhuan tag*/ /*flag2 shi kongzhi luquan jingdu de xunhuan tag*/ /*chushihua luquan shuzu he juli shuzu*/ double L[9][9]={ {0.00,4.20,inf,4.20,inf,inf,inf}, {4.20,0.00,4.20,inf,3.93,inf,inf,inf}, {inf,4.20,0.00,inf,inf,4.20,inf,inf,inf}, {4.20,inf,inf,0.00,1.96,inf,4.20,inf,inf}, {inf,3.93,inf,1.96,0.00,1.96,inf,3.93,inf}, {inf,inf,4.20,inf,1.96,0.00,inf,inf,4.20}, {inf,inf,inf,4.20,inf,inf,0.00,4.20,inf}, {inf,inf,inf,inf,3.93,inf,4.20,0.00,4.20}, {inf,inf,inf,inf,inf,4.20,inf,4.20,0.00}, };/*chushihua juli juzhen*/

main() { for(i=0;i<n;i++) { for(j=0;j<n;j++) { if (i!=j && L[i][j]<inf) v0=50; t0[i][j]=L[i][j]/v0; t[i][j]=t0[i][j]*(1+0.15*((v[i][j]/600)^4)); /*yi xiaoshi jisuan jingdu gao*/ } }/*jisuan chushi de luquan*/

/*kaishi xunhuan jisuan zuiduanlu,fenpei od,check jingdu*/ do { /*dang xunhuan dao di er ci yihou,xian jiang qian yi ci de luquan juzhen*/ /*he liuliang juzhen fuzhi gei t[][] he v[][],yi bian zuihou de shuchu*/ while(flag!=0) { for(i=0;i<n;i++) for(j=0;j<n;j++) { t[i][j]=t1[i][j]; v[i][j]=v1[i][j]; DS[i][j]=0;/*meici diedai zhi qian jiang ds[][] qingling ,chongxinfenpei*/ } } for(i=0;i<4;i++) for(j=0;j<4;j++) { shortestpath(jiedian[i],jiedian[j]); distribution(jiedian[i],jiedian[j]); } check(); } while(flag<=5 || (flag1*flag2)==0); shuchu(); } void shortestpath(int begin , int terminal) { double p[n]; /*p标号*/ double w[n]; /*t标号*/ int tag[n]={0} ; /*标记是否有p标号*/ int snode[n] ; /*记录附标号的点*/ int aa; int k,u; double pp; p[begin]=0.00 ; /*初始化*/ w[terminal]=0.00; k=begin; tag[begin]=1; for( i = 0 ;i<n;i++) { if (tag[i]==0) w[i]==rinf ; /*设无穷大为inf*/ for (aa = 1;aa<n;aa++) for (i = 0 ;i<n;i++) { if (tag[i]==0 && w[i]<p[k]+t[k][i]) { w[i] = w[i]; } else { w[i]=p[k]+t[k][i]; snode[i] = k; /*???*/ } } pp = inf; for (i = 0 ;i<n;i++) { if (tag[i] ==0 && pp > w[i]) { u = i; pp = w[i]; } } p[u] = pp; tag[u] = 1; k = u; }

} void distribution(int n1,int n2) { int theta1,theta2; for(j=0;j<9;j++) { while(snode[j+1]!=0)/*dang xia yi dian bu shi zhongdian shi*/ { theta1=snode[j]; theta2=snode[j+1]; /*youyu qiu zuiduanlu shi,zhi suan le n1<n2 de qingkuang*/ /*yinci fenpei shi yao jiang liang ge fangxiang de dou jia shangqu*/ DS[theta1][theta2]=DS[theta1][theta2]+OD[theta1][theta2]; DS[theta2][theta1]=DS[theta2][theta1]+OD[theta2][theta2]; v1[theta1][theta2]=DS[theta1][theta2]; v1[theta2][theta1]=DS[theta2][theta1]; } for(i=0;i<9;i++) for(j=0;j<9;j++) { t1[i][j]=t0[i][j]*(1+0.15*((v1[i][j]/600)^4)); } } } void check() { int q; double r; double deltat[n][n]; int deltav[n][n];/*yonglai jiang ge luduan de liuliang he*/ /*luquan de cha biaoshi chulai*/ ++flag; flag1=flag2=1; for(i=0;i<n;i++) for(j=0;j<n;j++) { deltat[i][j]=abs(t1[i][j]-t0[i][j]); r=(deltat[i][j]<0.01)?1:0; flag1=flag1*r;/*liancheng,zhiyoudang suoyou de r dou wei yi shi*/ /*flag1 cai huiwei1,fouze dou wei ling*/ deltav[i][j]=abs(v1[i][j]-v[i][j]); q=(deltav[i][j]<10)?1:0; flag2=flag2*q; } }

void shuchu() { int deltav[n][n]; double deltat[n][n]; printf("diandui v v1 t t1 deltav deltat\n"); for(i=0;i<9;i++) { for(j=0;j<9;j++) { if(L[i][j]!=0 && L[i][j]!=inf) { printf("%d %d %d %d %d %d %d %d\n",i+1,j+1,v[i][j],v1[i][j],t[i][j],t1[i][j],deltav[i][j],deltat[i][j]); } } } } 

搜索更多相关主题的帖子: include system double domain 
2005-06-29 16:17
快速回复:[求助]紧急求助~!!
数据加载中...
 
   



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

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