向量查询C ++疑问 [英] Vector query C++ doubt
本文介绍了向量查询C ++疑问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个值为10的矢量(即ID)我还有一个矢量,它有一些字符串..
i必须找到字符串值基于id = 10.
当id为10时我应该得到字符串值形式向量。
如何做到这一点。请告诉我。
not:id不是索引
i试过我得到的价值但是我希望用迭代器....
我尝试过的事情:
i have a vector which is having value 10( i.e ID) i have one more vector which is having some string ..
i have to find the string value based on the id = 10.
when the id is 10 i should get the string value form vector.
how to do that one. please let me know.
not : id is not index
i tried i got the value but i want with iterator....
What I have tried:
for (int i(0),n(foundRowIndices3.size()); i < n; i++)
{
if (foundRowIndices3.at(i) == nValue)
{
CString str = sDescription.at(i);
}
}
推荐答案
为什么不使用不同的集合类型,例如< a href =https://msdn.microsoft.com/en-us/library/s44w4h2s(v=vs.100).aspx>地图类 [ ^ ],它将值和字符串保持在一起。
Why not use a different collection type, such as the map Class[^], which keeps the value and string together.
建议:回到C / C ++基础。
C编程语言 - 维基百科,免费的百科全书 [ ^ ]
https://hassanolity.files.wordpress.com/2013/ 11 / the_c_programming_language_2.pdf [ ^ ]
http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf [ ^ ]
你不掌握循环的最基本语法。
看起来他们设法发明了一种更奇怪的语法。
所以i = 0
太简单了,他们通过使用函数调用语法i(0)
来设法进行模糊处理吗? />
他们让我参与了这个。
Advice: go back to C/C++ basics.
The C Programming Language - Wikipedia, the free encyclopedia[^]
https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[^]
http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[^]
You do not master to most basic syntax for the loop.
Looks they manage to invent an even weirder syntax.
Soi=0
was too simple and they managed to obfuscate by using the function calling syntaxi(0)
to do the same ?
They got me on this one.
这篇关于向量查询C ++疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文