#include "ui_resource_image.h"
#include "ui_resource_string.h"
#include "uicomponents/UIComponents.h"
-#include <cmath> // 包含数学函数库,用于四舍五入
+#include <cmath> // 包含数学函数库,用于四舍五入
+#include <iomanip> // 用于 std::setfill / setw 配速补零
#include <iostream>
#include <sstream> // 用于 std::ostringstream
#include <string> // 包含字符串处理库,用于使用 std::to_string
//特殊配置
if (TraingModel::GetInstance()->GetIsSpecial()) {
- // 平均配速
- // 需要计算一下 是秒 需要显示 分钟''秒''
- int totalSeconds = enddata->apc; // 总秒数
- int minutes = totalSeconds / 60; // 计算分钟
- int seconds = totalSeconds % 60; // 计算剩余秒数
- // 格式化为字符串
+ // 平均配速:显示为 分钟'秒"(如 5'05"),秒数补零避免误解
+ int totalSeconds = enddata->apc; // 总秒数(秒/公里)
+ int minutes = totalSeconds / 60;
+ int seconds = totalSeconds % 60;
std::ostringstream oss;
- oss << minutes << "'" << seconds << "\""; // 生成 "X'Y\"" 格式的字符串
- std::string avpaceStr = oss.str(); // 得到字符串
+ oss << minutes << "'" << std::setfill('0') << std::setw(2) << seconds << "\"";
+ std::string avpaceStr = oss.str();
if (labelavpace) // 检查标签是否为空
{
labelavpace->SetText(avpaceStr.c_str());