我有这段测试代码(还有很多其他材料;但是,它非常密集,可能与这个问题无关),它一直在产生一些莫名其妙的输出。编译时,此块:
cout << team1[m].rating << endl;
cout << team2[n].rating << endl;
cout << team1.size() << endl;
cout << team2.size() << endl;
cout << (team2[n].rating - team1[m].rating) / team2.size() << endl;
cout << (team1[m].rating - team2[n].rating) / team1.size() << endl;
产生输出:
10
30
2
2
10
2147483638
'team1' 和 'team2' 都是类型vector<player>
(没有反斜杠),并且 'player' 结构如下所示:
struct player {
string name;
int rating;
player(string Name, int Rating) :
name(Name), rating(Rating) {}
};