gpt4 book ai didi

C++ 将 0.00 转换为 00.00

转载 作者:行者123 更新时间:2023-11-28 01:51:05 25 4
gpt4 key购买 nike

<分区>

我无法将输出组织到项目的控制台中。所以我写了一个函数来在字符串上添加空格以正确格式化它。现在我遇到了问题,因为 0 不是小数点前的正确长度,而且它破坏了格式。如何将 0.00 更改为 00.00?这是我当前的功能:

void organize(string n[], double tstData[][COLUMN])
{
int j = 0;
string spaces[12] = {" "," "," "," "," "," "," "," "," "," "," "," "};

string holder = "";

for (int i = 0; i < 40; i++) {
if (n[i].size() < 17) {
j = 17 - n[i].size();
j = j - 1;
holder = n[i];
holder = holder + spaces[j];
n[i] = holder;
}

for (j = 0; j < 4; j++) {
if (tstData[i][j] == 0.00) {
tstData[i][j] = 00;
}
}
}
}

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