lundi 23 février 2015

Why I have a Segmentation fault in this small program?


#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;

int main() {
map<int, int> score;
int n;
cin >> n;
while(n--){
int a,b;
cin >> a >> b;
score[a] = score[a] + b;
}
cout << score.rbegin()->first << " " << score.rbegin()->second << endl;
return 0;
}


the error message is 16254 segmentation fault::11. Exit code: 139. And could you please why segmentation fault frequently happened when using map container.


Aucun commentaire:

Enregistrer un commentaire