Home > Back-end >  A student in the class under the condition of the subscript may not sure how it is modified through
A student in the class under the condition of the subscript may not sure how it is modified through

Time:12-30

Stu arrstu [1200]=
{
Line (_T (" zhang "), 0.4, 0.6, Color (0, 0), 1, 1),
The line (_T (" li si "), 0.4, 0.6, Color (25, 25112), 1, 2),
The line (_T (" detective "), 16000, 22000, Color (205, 38, 38), 2, 1),
The line (_T (" z "), 8000, 15000, Color (31), 156102, 2, 2),
. Later still has a lot of
};
I want to directly through someone's name, such as zhang SAN to get his grades or modify points how to implement? I know by arrstu [0]. Score to get or modify, but when not remember zhang SAN in the array position in the table below, may be in 1000 or 999 when how to do? Want to use a hash table but a string associated with an object, want to use the container without vector. The find () this functionality, strives for the big show how to achieve?

CodePudding user response:

First, the string can be used as a STD: : map key, second, names could be repeated, the only should be a student id, should get information by student number and modify.

CodePudding user response:

Time array name and group membership of pointer stored in the map, using the map to find operations

CodePudding user response:

You can use a map, a student id or name to do the key, students do the value class, according to the key value can find,

CodePudding user response:

Also, "want to use the container without vector. The find () function of the" this sentence is a problem, c + + class, provides the algorithm with global inside the find function, can be used to find the data in the vector, the result is an iterator that can modify the score of the iterator, specific usage can baidu,

CodePudding user response:

reference 1st floor ggglivw response:
first, string can be used as a STD: : map key, second, names could be repeated, should be the only student id, should get information by student number and modify.
I repeated this don't have to consider, I know the string can be used as a key to use, I want effects are & lt; String, the line (_T (" zhang "), 0.4, 0.6, Color (0, 0), 1, 1) & gt; And then modify the object directly by the string inside the line parameter, if is to get the student id, how to get score? I know with array arrstu [I] score can modify the score, the problem is I'm not sure I position? This I determined by what what method can query?
  • Related