gpt4 book ai didi

c++ - 仅在行不为空时递增

转载 作者:行者123 更新时间:2023-11-28 08:07:46 25 4
gpt4 key购买 nike

我正在用 vector 填充 table 但是 vector 中有一些 empty cells 并且我如果单元格不为空,只想创建一个新行,但表格不喜欢这样,因为它希望行号递增一个

1,2,3,4,5

如果它是 empty 它将像 THIS IS WHERE THE ERROR OCCURS1,2,4,5

那么,当一个单元格为并且只有一个单元格有内容时,我怎样才能让它不increment,所以它保持不变喜欢

1,2,3,4,5

代码

int it = 0;
while(it < popLocatedErrorColumn.size())
{
if(popLocatedErrorColumn[it] != "")
{
DCS_GET_HTMLKIT_REPETITION(uldtable, uldRow,NULL,it);
if(uldRow.getItem("locatedError"))
uldRow.getItem("locatedError")->setValue(popLocatedErrorColumn[it]);
}
it++;
}

最佳答案

使用第二个整数索引来跟踪当前行号。

    int it = 0, index = 0; 
while(it < popLocatedErrorColumn.size())
{
if(popLocatedErrorColumn[it] != "")
{
DCS_GET_HTMLKIT_REPETITION(uldtable, uldRow,NULL,index);
index++;
if(uldRow.getItem("locatedError"))
uldRow.getItem("locatedError")->setValue(popLocatedErrorColumn[it]);
}
it++;
}

关于c++ - 仅在行不为空时递增,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9910701/

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