如题,p.tagH这个字符串常量有经过初始化,但是最后输出的值却意外的变0
完全不理解
#include
#include
#include
class humidex
{
public:
float temperature, dewpoint,humidexa;
char tagT,tagD,tagH;
float humidex0(float temperature,float e)
{
float h;
h = (0.5555)*(e - 10.0);
return temperature + h;
}
float exp0(float n)
{
return 6.11*exp(5417.7530*((1 / 273.16) - (1 / (n + 273.16))));
}
};
int main()
{
int i, j, k, m, n;
humidex p;
char b;
float h;
p.tagH='H';
printf("%c\n", p.tagH);
while (scanf("%s%f%s%f", &p.tagT,&p.temperature,&p.tagD,&p.dewpoint)!= EOF)
{
p.humidexa = p.exp0(p.dewpoint);
h=p.humidex0(p.temperature,p.humidexa);
// printf("%c\n", p.tagH);
if (h-(int)h> 0.5)
{
h = (int)h+1.0;
}
// printf("%s\n", p.tagH);
printf("%c %0.1f %c %0.1f %c %0.1f\n",p.tagT,p.temperature,p.tagD,p.dewpoint,p.tagH,h);
}
scanf("%s", &b);
return 0;
}