-1
And if so, change the value of the previously added pair instead of adding a new pair.
So, I’d like to add string pairs, int into an array, only, to avoid redundant pairs, check if the string already exists and instead of adding a duplicate value to the array, update an existing one. The intention is to store a player’s name and score. What is the best way? It is 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));
}
}