为什么这个函数不输出小数

 红白蓝2502891727 发布于 2023-02-12 11:46

我有一个功能:

void LocalMax(vector Entry , int Size)
{
    int Highest1 = 0, Highest2 = 0, Highest3 = 0, Temp = 0, Highest = 0;
    double TempDouble;
    for (int i = 0; i < Size - 1; i++)
    {
        Temp = Entry[i].MaxTemp;
        if (Temp > Highest) {Highest = 0; Highest = Temp;}
        if (Entry[i].StationID != Entry[(i + 1)].StationID)
            {
                if (Entry[i].StationID == "GHCND:USC00083909") {Highest1 = Highest; Highest = 0;}
                if (Entry[i].StationID == "GHCND:USW00012888") {Highest2 = Highest; Highest = 0;}
                if (Entry[i].StationID == "GHCND:USR0000FCHE") {Highest3 = Highest;}
            } else if (Temp > Highest) {Highest = Temp; Temp = 0;}
        if (i == Size - 2) {Highest3 = Highest;}
    }
    TempDouble = Highest1 / 10;
    cout << "The highest temp recorded for Station1 was: " << Highest1 << " tenths of a degree Celsius \nor: " << TempDouble << " degrees Celsius." << endl;
    TempDouble = Highest2 / 10;
    cout << "The highest temp recorded for Station2 was: " << Highest2 << " tenths of a degree Celsius \nor: " << TempDouble << " degrees Celsius." << endl;
    TempDouble = Highest3 / 10;
    cout << "The highest temp recorded for Station3 was: " << Highest3 << " tenths of a degree Celsius \nor: " << TempDouble << " degrees Celsius." << endl;
}

这给了我:

The highest temp recorded for Station1 was: 339 tenths of a degree Celsius
or: 33 degrees Celsius.
The highest temp recorded for Station2 was: 350 tenths of a degree Celsius
or: 35 degrees Celsius.
The highest temp recorded for Station3 was: 344 tenths of a degree Celsius
or: 34 degrees Celsius.

为什么TempDouble没有显示任何小数?任何澄清都会很棒!提前致谢.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有