我需要找出每個人有多少票。我有一個數字來計算有多少個候選人在場,這個候選人的數量是5.現在我有一大堆來自數組列表的數字,我需要計算每個候選人的快樂投票數以及候選人數的變化取決於我使用的數組列表,但是用於測試目的,我使用TEST5其中有5追蹤多少個數字和計數器
//Numbers from arraylist:
1
1
2
5
2
5
5
5
,這是我的代碼
// My code
for (int i=1; i <output.size(); i++){
char checkBallot = output.get(i).charAt(1);
//candidate is array to track how many output as what
// output is array of numbers I want to count.
String aString = Character.toString(checkBallot);
int c = Integer.parseInt(aString);
int b = c;
for (int p= 0; p < count; p++){
if(c == p+1){
int oldvalue =0;
candidate[c] = c+ oldvalue ;
oldvalue = c ;
System.out.println("this is the counter:" +c);
}
}
問題是什麼嗎? – 2011-06-03 00:33:08
另外,粘貼代碼的其餘部分...輸出是什麼?州?候選人? etc – Bohemian 2011-06-03 00:35:35
輸出是從數組列表狀態的數字是它現在狀態的順序是1。候選者是一個數組,用於跟蹤輸出中有多少個1 2 3 4 5。對不起,我寫我想達到的東西太可怕了。 – 2011-06-03 00:51:59