2013-07-29 55 views
-3
 
     abcd Dy Ff ss Pre C q 
oops  8 0 0 0 0 2 0 
GROUP C1 0 0 0 0 0 0 0 
GROUP C2 0 0 0 0 0 1 0 
GROUP D1 0 0 0 0 0 0 0 
GROUP D2 0 0 0 0 0 0 0 
GROUP E  0 0 0 0 0 0 0 

我已經得到了如上的說,哎呀是一個ArrayList中,C1組到E是從結果向量得到逐列總和需要

我試圖讓和逐列像

 
TOTAL 8 0 0 0 0 3 0 

我不知道如何實現,謝謝你提前。

我已經嘗試了一些事情來獲取值。

int j=1; 
    for(int i=0;i<=5;i++) 
    { 
     out.print(((ArrayList)oRoleList.get(i)).get(j)); 
    }  

int q=2; 
for(int w=0;w<=5;w++) 
    { 
     out.println(((ArrayList)(Vector)oBandList.get(w)).get(q)); 
    } 

,但我沒有得到exaclty如何獲取和縱列

+6

[你有什麼試過?](http://mattgemmell.com/2008/12/08/what-have-you-tried) –

+0

代碼請.... – rahulserver

+0

請不要downvote,請幫我出去即時通訊嘗試這從早上但無法實現:( – user2611604

回答

0

假設oops == {1, 2, 3, 4, 5, 6},和矢量是v == {1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6} // 3 ROWS(難道我給你正確的?),和ROWS == 3columns == 6。然後accumulator = oops[position],即我們把它初始化到相應的oops條目,你可以做

for (int i = 0; i < ROWS; i++) { 
    accumulator += v[position + i * COLUMNS] 
} 

所以,如果你需要總結在第三列:在初始階段accumulator == oops[2] == 3,然後你做accumulator += v[2] // == 3等。 只需更改代碼以符合您的價值觀即可。