首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

各位大神帮帮忙呀,调试结果出错,该怎么解决

2012-06-05 
各位大神帮帮忙呀,调试结果出错为什么下面一段程序,运行时结果不是1就是0呢?求大家帮帮忙呀float app,acp,

各位大神帮帮忙呀,调试结果出错
为什么下面一段程序,运行时结果不是1就是0呢?求大家帮帮忙呀
float app,acp,apc,acc,cpp,ccp,cpc,ccc;
float upp,ucp,upc,ucc,uin,npp,ncp,npc,ncc,nf;
float fpp,fcp,fpc,fcc;
AnsiString tmp;
float T;
if(Trim(temedi->Text)=="")
{
MessageBoxEx(Handle,"请输入温度","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
temedi->Text="";
temedi->SetFocus();
return; }
if(Trim(uppedi->Text)=="")
{
MessageBoxEx(Handle,"请输入低周疲劳应变范围","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
uppedi->Text="";
uppedi->SetFocus();
return; }
if(Trim(ucpedi->Text)=="")
{
MessageBoxEx(Handle,"请输入拉伸蠕变应变范围","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
ucpedi->Text="";
ucpedi->SetFocus();
return; }
if(Trim(upcedi->Text)=="")
{
MessageBoxEx(Handle,"请输入压缩蠕变应变范围","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
upcedi->Text="";
upcedi->SetFocus();
return; }
if(Trim(uccedi->Text)=="")
{
MessageBoxEx(Handle,"请输入拉压蠕变应变范围","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
uccedi->Text="";
uccedi->SetFocus();
return; }
try
{
StrToFloat(Trim(temedi->Text));
}
catch(...)
{MessageBoxEx(Handle,"温度不是有效数字","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
temedi->SetFocus();
return;}
try
{StrToFloat(Trim(uppedi->Text));
}
 catch(...)
{MessageBoxEx(Handle,"低周疲劳应变范围不是有效数字","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
uppedi->SetFocus();
return;}
try
{StrToFloat(Trim(ucpedi->Text));
}
 catch(...)
{MessageBoxEx(Handle,"拉伸蠕变应变范围不是有效数字","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
ucpedi->SetFocus();
return;}
try
{StrToFloat(Trim(upcedi->Text));
}
 catch(...)
{MessageBoxEx(Handle,"压缩蠕变应变范围不是有效数字","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
upcedi->SetFocus();
return;}
try
{StrToFloat(Trim(uccedi->Text));
}
 catch(...)
{MessageBoxEx(Handle,"拉压蠕变应变范围不是有效数字","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
uccedi->SetFocus();
return;
}
upp= StrToFloat(Trim(uppedi->Text));
ucp= StrToFloat(Trim(ucpedi->Text));
upc= StrToFloat(Trim(upcedi->Text));
ucc= StrToFloat(Trim(uccedi->Text));
uin=upp+ucp+upc+ucc;
T=StrToFloat(Trim(temedi->Text));
if(T<0)
{MessageBoxEx(Handle,"温度不能为负值","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
temedi->SetFocus();
return;}
if(upp<0)
{MessageBoxEx(Handle,"低周疲劳应变范围不是为负值","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
uppedi->SetFocus();
return;}
if(ucp<0)
{MessageBoxEx(Handle,"拉伸蠕变应变范围不是为负值","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
ucpedi->SetFocus();
return;}
if(upc<0)
{MessageBoxEx(Handle,"压缩蠕变应变范围不是为负值","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
upcedi->SetFocus();
return;}
if(ucc<0)
{MessageBoxEx(Handle,"拉压蠕变应变范围不是为负值","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
uccedi->SetFocus();
return;}if((upp=0&&ucp=0&&upc=0&&ucc=0)
{MessageBoxEx(Handle,"应变范围不能都为零","信息",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE);
uppedi->SetFocus();
return;}
T=273.15+T;
if(ComBox->ItemIndex==0)
{app=2418.87378-4.32836*T+0.00194*T*T;
cpp=-49.86213-0.08866*T-3.9846E-5*T*T;
acp=-44.50029+0.08171*T-3.71107E-5*T*T;
ccp=7.30179-0.01504*T+7.322E-6*T*T;


apc=-34.86974+0.06312*T-2.8218E-5*T*T;
cpc=6.27903-0.01253*T+5.87867E-6*T*T;
acc=1.25005-7.0084E-4*T-1.1E-7*T*T;
ccc=-18.6436+0.03079*T-1.28627E-5*T*T;}
else 
{app=3343.56302-6.31838*T+0.003*T*T;
cpp=-31.25149+0.05795*T-2.75053E-5*T*T;
acp=4.67322-0.00794*T+3.66467E-6*T*T;
ccp=-5.96088+0.00819*T-2.76133E-6*T*T;
apc=-96.21416+0.1808*T-8.4014E-5*T*T;
cpc=47.59031-0.09188*T+4.37073E-5*T*T;
acc=-85.52989+0.16358*T-7.75347E-5*T*T;
ccc=-0.18419+7.54376E-4*T-9.89333E-7*T*T;}
try
{
if(upp<10E-6)
{npp=1;
fpp=0;
}
else
{
npp=pow(upp*app,cpp);
fpp=upp/uin;
}
if(ucp<10E-6)
{
ncp=1;
fcp=0;}
else
{
ncp=pow(ucp/acp,1/ccp);
fpp=ucp/uin;
}
if(upc<10E-6)
{
npc=1;
fpc=0;
}
else
{
npc=pow(upc/apc,1/cpc);
fpc=upc/uin;
}
if(ucc<10E-6)
{
ncc=1;
fcc=0;
}
else
{
ncc=pow(ucc/acc,1/ccc);

fcc=ucc/uin;
}
nf=1/(fpp/npp+fcp/ncp+fpc/npc+fcc/ncc);
tmp=ComBox->Text+"在"+Trim(temedi->Text)+"°C"+"疲劳寿命是"
+IntToStr(int(nf+0.5))+"周。";
MessageBoxEx(Handle,tmp.c_str(),"预测结果",
MB_OK|MB_ICONINFORMATION,LANG_CHINESE); }
catch(...)
{
MessageBoxEx(Handle,"请输入正确的应变范围数据.","错误",
MB_OK|MB_ICONERROR,LANG_CHINESE);
return;}
}


[解决办法]
nf=1/(fpp/npp+fcp/ncp+fpc/npc+fcc/ncc)之后打印一下这几个浮点型变量的值

热点排行