weixin_52487830 2020-12-21 23:20 采纳率: 66.7%
浏览 35
已采纳

求大佬看问题,和书上答案一模一样,为啥报错呢?

以下为书上代码:

#include<stdio.h> 
int Temperatures(double hswd );
int main(int argc,char*argv[]){
	double input;
	
	printf("enter the temperatures:");
	while(scanf("%lf",&input)==1){
		Temperatures(input);
	printf("vdxjsahbcj");
	}
	printf("this is the problem withe the number you entered! ");
	return 0;
	
}
	int Temperatures(double hswd ){
	
		const double f_to_c=32.0;
		const double c_to_k=273.16;
		
		double sswd,kswd;
		
		sswd=5.0/9.0*(hswd-f_to_c);
		kswd=sswd+c_to_k;
		printf("%.2f华氏温度计,%.2f摄氏温的,%.2f开氏温度\n",hswd,sswd,kswd);
	
		return 0;
	}

错误:

以下为在论坛找的代码:

#include<stdio.h> 
void Temperatures(const double temperature)
{
    const double Fahrenheit_val = 32.0;
    const double Kelvin_val = 273.16;
    const double Fahrenheit_temp = 5.0 / 9.0 * (temperature - Fahrenheit_val);
    const double Kelvin_temp = temperature + Kelvin_val;
 
    printf("Celsius: %.2lf  Fahrenheit:%.2lf  Kelvin:%.2lf\n", temperature, Fahrenheit_temp, Kelvin_temp);
    return;
}
void p5_9(void)
{
    double temperature = 0.0;
 
    printf("please enter the temperature (q to quit):");
    while (scanf_s("%lf", &temperature) == 1)
    {
        getchar();
        Temperatures(temperature);
        printf("please enter the temperature (q to quit):");
    }
 
    return;
}
 
 
int main(int argc, char **argv)
{
    p5_9();
 
    getchar();
 
    return 1;
}
 

我以为是我软件的问题,因为它也点不开调试,用了mooc的在线语言开发环境:

  • 写回答

3条回答 默认 最新

  • lishengmin_ 2020-12-22 10:11
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程