求解决办法!!!!!!
c语言吧
全部回复
仅看楼主
level 1
#include <stdio.h>
int main()
{
const float a = 1.8;
const float b = 32.0;
const float c = 273.16;
double hua,she,jue;
char ch[10];
int i=0,j=0;
printf("请输入华氏温度\n");
while(j != 1)
{
scanf("%lf", &hua);
ch = hua;
while(ch[i] != '\0')
{
if(ch[i] >= '0' && ch[i] <='9')
{
i++;
}
else
{
j = 1;
printf("您输入的温度有误\n");
break;
}
}
if(j != 1)
{
she = a * hua + b;
jue = she + c;
printf("华氏温度:%.2lf\n", hua);
printf("摄氏温度:%.2lf\n", she);
printf("绝对温度:%.2lf\n", jue);
}
}
return 0;
}
其实我也猜到是哪里错了,苦逼的是不知道怎么解决
2014年12月02日 02点12分 1
level 14
ch = hua;[真棒]
2014年12月02日 02点12分 2
我也看到了,怎么解决啊
2014年12月02日 02点12分
sprintf是什么,还没学到
2014年12月02日 02点12分
回复 儒雅的大众大神 :和printf差不多,只是这个是吧变量格式化到数组中
2014年12月02日 02点12分
level 14
可以用sprintf函数将你的浮点数转换成字符串
2014年12月02日 02点12分 3
为何要用字符串来呢[疑问][疑问][疑问]
2014年12月02日 02点12分
回复 光棍一声笑 :那你明白我这是要干嘛的吗?
2014年12月02日 02点12分
1