gpt4 book ai didi

c++ - 下面的代码应该为 4 和 0 的输入打印 120.000000。但它只显示 120。为什么?以及如何获得所需的输出?

转载 作者:行者123 更新时间:2023-11-28 06:41:10 26 4
gpt4 key购买 nike

#include <iostream>
using namespace std;

int main()
{
float deg;
int h,m;
cin>>h>>m;
deg=h*30 - m*6;
cout<<deg;
return 0;
}

h 和 m 是小时和分钟

问题以度为单位找出时针和分针之间的角度。

最佳答案

cout<< 固定;是答案

#include <iostream>
using namespace std;
int main()
{
float deg;
int h,m;
cin>>h>>m;
deg=h*30 - m*6;
cout<<fixed;
cout<<deg;
return 0;
}

关于c++ - 下面的代码应该为 4 和 0 的输入打印 120.000000。但它只显示 120。为什么?以及如何获得所需的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25919414/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com