华为机试题 合并表结构

简介

简单

code

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    
    int k, v;
    map<int, int> m;
    for(int i = 0; i<n; i++){
        cin >> k >> v;
        m[k] += v;
    }
    for(auto it : m){
        cout << it.first << " " << it.second << endl;
    }
    return 0;
}
Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
原文地址:https://www.cnblogs.com/eat-too-much/p/14919879.html