下面的代码应该为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?

本文关键字:为什么 显示 输出 何获得 000000 代码 打印 输入      更新时间:2023-10-16
#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;
}