根据选择从列表中检索值。 [英] Retrieve the value from the list based on the selection.
本文介绍了根据选择从列表中检索值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据选择检索值。
示例:以下是示例列表
名称价值温度
A 1 S
B 2 D
C 3 W
D 4 E >
E 5 F
我需要根据名称选择获取值(假设名称在下拉列表中)。
如果我从下拉菜单中选择C,我应该得到3个值对应它
如果我选择D,我应该得到4值
任何链接或帮助,以便它可以帮助将被赞赏
我尝试过:
Retrieve the value based on the selection.
Example : Below is the sample list
Name Value Temp
A 1 S
B 2 D
C 3 W
D 4 E
E 5 F
I need to get the value based on the Name selection(Suppose name is in the dropdown).
If i select C form the drop down,i should get the 3 value corrsponding to it
If i select D,i should get the 4 value
Any link or help so that it can help will be appreciated
What I have tried:
Retrieve the value based on the selection.
Example : Below is the sample list
Name Value Temp
A 1 S
B 2 D
C 3 W
D 4 E
E 5 F
I need to get the value based on the Name selection(Suppose name is in the dropdown).
If i select C form the drop down,i should get the 3 value corrsponding to it
If i select D,i should get the 4 value
Any link or help so that it can help will be appreciated
推荐答案
有几种方法可以实现它。
一个简单的方法是使用std :: map< char,int =>< / char,>
来持有名称
和值
值(例如,参见 std :: map :: operator [] - cppreference.com [ ^ ])。
There are several ways to implement it.
A simple approach would use astd::map<char, int=""></char,>
for holding theName
andValue
values (see, for instance std::map::operator[] - cppreference.com[^]).
这篇关于根据选择从列表中检索值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文