> 其他 >
C语言编程:输入一个华氏温度,要求输出相应摄氏温度,c=5/9(f-32)保留2位小数
人气:308 ℃ 时间:2020-06-06 12:55:46
解答
int main(){
float c,f;
printf("please input the f=");
scanf("%f",&f);
c=5/9*(f-32);
printf("the c=%f",c);
}你运行了么,不行啊,组建的时候还是有个错误C:\Documents and Settings\Administrator\桌面\温度转换.cpp(7) : error C2065: 'F' : undeclared identifier.cpp(7) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data.cpp(9) : warning C4508: 'main' : function should return a value; 'void' return type assumed执行 cl.exe 时出错.作业.exe - 1 error(s), 0 warning(s)int main(){float c,f;printf("please input the f=");scanf("%f",&f);c=5.0/9*(f-32);printf("the c=%.2f",c);} 你再完整的复制下这个试试。你上面提示的那个错误明显是你没有完全复制我的,因为我的程序里都没有用到大写的F。
推荐
猜你喜欢
© 2025 79432.Com All Rights Reserved.
电脑版|手机版