下面的代码应该为4和0的输入打印120.000000。但它只显示 120。为什么?以及如何获得所需的输出?
The below code is supposed to print 120.000000 for an input of 4 & 0. But it shows only 120. Why? and how to get desired output?
#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的循环中使用printf的Rust代码不显示输出,而在C++的循环中显示std::cout
- 为什么我的程序不能显示斐波那契级数?
- 为什么C++总是显示十六进制内存地址,而不仅仅是整数?
- 为什么静态数组成员变量在调用对象的实例后不显示任何内容?
- 为什么当 vector 为空时会显示运行时错误?
- 为什么将指针重新分配给 1D 数组的 char 时显示错误,但 2D 数组工作正常?
- 为什么我的 cout 在输出中没有显示字符串?
- 为什么下面的Hello World程序在PowerShell上没有显示任何输出?同一程序在CMD上显示正确的输出
- 为什么strlen(s)与s的大小不同,为什么cout-char显示的是字符而不是数字
- 为什么在为其分配编号后无法显示我的字符串值?
- 为什么输出窗口上没有显示输出?
- 为什么C++在将浮点数转换为字符时没有显示缩小转换错误?
- 为什么C++显示错误的数字?
- 为什么显示错误:参数太少而无法正常工作
- C++/openCV - 为什么显示图像会产生 Linux 分割错误?(打开CV错误?
- 为什么显示密码而不是消息
- 谁能解释这个代码?为什么显示 1
- 为什么显示的颜色不是VTK中预期的颜色
- 为什么显示 - "cannot pass objects of non-trivially-copyable type"?
- 为什么显示"Received a connection from 0.0.0.0, port 0"?