This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit 115f6efa authored by OEResource sharing's avatar OEResource sharing
Browse files

OEResource: Update resource with id: 5db45e18-3cf8-46a0-bc06-d4bdc0b17275

parents
Branches
No related merge requests found
## Ersetzen von Nullen durch den Durchschnitt der Spalte
#### Aufgabenstellung:
Implementieren Sie eine Methode `replaceZerosWithColumnAverage`:
- `void replaceZerosWithColumnAverage(int[][] workArray)`
Diese Methode akzeptiert ein zweidimensionales Array von Ganzzahlen und struktuiert dieses um, indem alle Nullen durch den Durchschnitt der entsprechenden Spalte ersetzt werden.
**Vorbedingungen:**
- `workArray` ist nicht null (`workArray != null`).
- Die Länge des Arrays `workArray` ist größer als 0 (`workArray.length > 0`).
- Für alle gültigen Indizes `i` gilt: Die Länge der Zeile `workArray[i]` ist größer als 0 (`workArray[i].length > 0`).
***Hinweis:*** Sie können den Ausdruck `System.out.println(Arrays.deepToString(workArray));` verwenden, um das umstruktuierte Array auszugeben.
#### Beispiele:
```
Eingabe:
{{1, 0, 5},
{6, 0, 1},
{0, 7, 0}}
Erwartete Ausgabe:
1 2 5
6 2 1
2 7 2
Eingabe:
{{1, 5, 6, 0},
{1, 9, 0},
{4, 0},
{0, 3, 0, 6, 2},
{6, 3, 0}}
Erwartete Ausgabe:
1 5 6 3
1 9 1
4 4
2 3 1 6 2
6 3 1
```
\ No newline at end of file
audience: Experienced
creator:
- affiliation: Technische Universität Wien
email: nadja.jovancevic@tuwien.ac.at
name: Nadja Jovancevic
description: Man sollte alle Vorkommen von null in einem Array durch den Durchschnitt
der entsprechenden Spalte ersetzen.
difficulty: medium
format:
- md
keyword:
- If conditionals
- For loops
- Arrays
- 2D arrays
language:
- de
learningResourceType: Programming exercise
license: CC BY 4.0
metadataVersion: '0.5'
programmingLanguage:
- Java
publisher:
- affiliation: Technische Universität Wien
email: nadja.jovancevic@tuwien.ac.at
name: Nadja Jovancevic
teaches:
- Java/Data Structures/Multidimensional Arrays
- Java/Controlflow/Loops/For
- Java/Controlflow/Loops/For-Each
- Java/Controlflow/Conditionals/If Statements
timeRequired: 15-30 min
title: Ersetzen von Nullen durch den Durchschnitt der Spalte
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment