#46701: 可以只用 map,但要加iomanip


ck1090932@gl.ck.tp.edu.tw (陳邦仁)


假設要找map m裡面有沒有 a 這個key的話,判斷m.find(a)==m.end() 為True就行;

輸出的話,我害怕當時有int不滿五位數會有前輟0的問題,我是這樣寫(要寫#include<iomanip>):

for (auto it=m.begin();it!=m.end();it++){
    cout<<setw(5)<<setfill('0')<<it->first;
    cout<<" "<<it->second<<"\n";
}