Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Matrix verändern

Empfohlene Antworten

Veröffentlicht

Also habe folgende Aufgaben: 1.Schreiben Sie eine C-Funktion, die für eine 5×5-Matrix das größte Element zurück liefert.Welche

Typdeklaration ist dazu notwendig? 2.Wie ist die Funktion zu verändern, wenn neben dem Wert des Elementes auch dessen Position

in der Matrix ermittelt werden soll?

Meine Lösung zu 1.:

#include <stdio.h>

int matrixc(int input[5][5]);

int main() {

int output;

int matrix[5][5] = {

{1,2,3,4,5},

{5,6,7,8,9},

{4,3,2,1,9},

{1,2,3,4,5},

{0,0,0,0,2}};

// Aufruf der Funktion, die du schreiben sollst

// Dabei wird die Matrix übergeben

output = matrixc(matrix);

// Kann man auch noch ausgeben, um besser zu kontrollieren

printf("%d\n", output);

}

// Und die schreibst du dann:

int matrixc(int input[5][5]) {

// lokale Variablen

int i,z;

int high = input[0][0]; // Anfangswert ist der erste Wert

/**

* Nun für jede Zeile und Spalte durchlaufen

* und dabei immer das Element speichern, welches

* größer ist, als das aktuelle Element.

*/

for (i=0; i < 5; i++) {

for(z=0; z < 5; z++) {

if (input[z] > high) {

high = input[z];

}

}

}

return high;

}

und 2. weiß ich nicht was ich verändern soll bzw dazukommt

Du musst doch dann nur noch zusätzlich die i/z-Koordinaten abspeichern, wenn die IF-Bedingung zutrifft. Die Position wird nur durch i und z bestimmt.

also muss ich i und j noch ausgeben oder wie?

kann mir einer sagen wie das geht? also der cod

ok denn werde ich es mal versuchen;)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.