谁能帮小弟做一道C语言的题?

来源:百度知道 编辑:UC知道 时间:2024/05/24 04:07:52
数日一个华氏温度,要求输出摄氏温度。公式为c=5/9(F-32)
输出要求有文字说明,取两位小数

#include<iostream.h>

int main()
{
float huashi,sheshi;
cout<<"\n请输入一个华氏温度";
cin>>huashi;
sheshi=5/9*(huashi-32);
cout.setf(ios::fixed|ios::showpoint);
cout.precision(2);//输出2位小数
cout<<"\n摄氏温度为"<<sheshi<<"度";
return 0;
}
大概就是这样 运行有点问题 主要是你公式有问题
你在看下 把我的公式改下就行了;

#include <stdio.h>
main()
{int a,b;
scanf("%d",&a); /*接受输入的华氏温度*/
b=5/9*(a-32); /*计算摄氏温度*/
printf("\n%d",b);/*输出摄氏温度*/
}

#include"stdio.h"
main()
{
double f,c;
printf("input f :\n");
scanf("%lf",&f);
c=5.0/9*(f-32);
printf("\nthe c is %f",c);
}

#include <stdio.h>

void main()
{
/*定义变量c为摄氏温度,F为华氏温度*/
float c,F;
printf("请输入华氏温度:"