And if you have, change the value of the previously added pair instead of adding a new pair.
So, I would like to add string, int pairs into a vector, except that, to avoid redundant pairs, check if the string already exists and instead of adding a duplicate value to the vector, update an existing one. The intent is to store a player's name and punctuation. What is the best way? Is it possible?
#include <bits/stdc++.h>
#define psi pair<string, int>
#define mp make_pair
using namespace std;
int numround(int&);
void validate(string, int);
int main(){
int n, score = 0;
string name = "";
vector<psi> v;
numround(n);
for (int i = 0; i < n; ++i){
cout << "Enter name[32] and score[-1000 ~ 1000]: " << endl;
cin >> name;
cin >> score;
validate(name, score);
v.push_back(mp(name,score));
}
}