forked from IF-LK-2020/arrays2
rowSum
This commit is contained in:
11
Arrays.java
11
Arrays.java
@@ -126,8 +126,15 @@ public class Arrays {
|
||||
* @return Ein eindimensionales Array mit den Zeilensummen
|
||||
*/
|
||||
public int[] rowSum( Wuerfel[][] pArray ) {
|
||||
// TODO: implementieren
|
||||
return null;
|
||||
int[] rowSum = new int[pArray.length];
|
||||
for (int i = 0; i < pArray.length; i++) {
|
||||
for (Wuerfel w : pArray[i]) {
|
||||
if (w != null) {
|
||||
rowSum[i] += w.getAugenzahl();
|
||||
}
|
||||
}
|
||||
}
|
||||
return rowSum;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user