题目大意:已知三个变量间的关系,给出两个变量,求第三个变量。
解题思想:输入方式两层循环,外层为while。
标记所求变量,选择合适公式。
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
double h,t,d;
bool bH,bT,bD;
char strOpt[10];
int main()
{
while(scanf("%s",strOpt),strcmp(strOpt,"E"))
{
double val;
scanf("%lf",&val);
if(strOpt[0]=='T')
{
t=val;
bT=true;
}
else if(strOpt[0]=='D')
{
d=val;
bD=true;
}
else
{
h=val;
bH=true;
}
scanf("%s%lf",strOpt,&val);
if(strOpt[0]=='T')
{
t=val;
bT=true;
}
else if(strOpt[0]=='D')
{
d=val;
bD=true;
}
else
{
h=val;
bH=true;
}
if(!bH)
{
double th,te;
te=6.11*exp(5417.7530*((1/273.16)-(1/(d+273.16))));
th=0.5555*(te-10.0);
h=t+th;
}
else if(!bT)
{
double th,te;
te=6.11*exp(5417.7530*((1/273.16)-(1/(d+273.16))));
th=0.5555*(te-10.0);
t=h-th;
}
else
{
double th,te;
th=h-t;
te=th/0.5555+10.0;
d=-1/(log(te/6.11)/5417.7530-1/273.16)-273.16;
}
printf("T %.1f D %.1f H %.1f\n",t,d,h);
bH=bT=bD=false;
}
return 0;
}
while(,strpot!='E') 不懂用字符的条件判断语句错在哪里。