IHAVE一個載體,它包含monthyearC++找到相同的記錄在矢量
Jan2013 Jan2013 Jan2013 Jan2014 Jan2014 Jan2014 Jan2014 Feb2014 Feb2014
基本上就是我想要做的就是通過搜索對於每個相同的記錄,該載體將它們組合在一起,如 ,例如
total count for Jan2013 = 3;
total count for Jan2014 = 4;
total count for Feb2014 = 2;
當然,因爲我們知道,我們只要簡單地寫多,如果要解決它
if(monthyear = "Jan2013") {
//add count
}
if(monthyear = "Jan2014") {
//add count
}
if(monthyear = "Feb2014") {
//add count
}
,但絕不是一個程序員是怎麼回事代碼它以這種方式。 如果還有額外的年份,2014年4月,2014年4月,2014年5月,一直到2014年12月 和2015年1月 - 2015年12月等。
我不認爲我應該在長期運行中採用這種硬編碼方法,並尋找更動態的方法。
我不要求代碼,但只是一些步驟,也許給我一些提示,我應該研究什麼樣的C++方法。
在此先感謝
請務必在if語句中使用'monthyear ==「... 2014」'。 – lcs