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条)

报告相同问题?

悬赏问题

  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 ARIMA模型时间序列预测用pathon解决
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序,怎么查看客户esp32板子上程序及烧录地址
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)