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.

Arrays Addieren

Empfohlene Antworten

Veröffentlicht

Hi Leute die Aufgabe ist 2 arrays zu addieren und das dann in einem 3ten auszugeben.

#include <stdio.h>

#include <conio.h>

#include <iostream.h>

#include <vcl.h>

void main(void)

{

int A[3][2]={{3,2},{4,5},{2,1}};

int B[2][2]={{1,7},{5,9}};

int C[3][2];

int i,k,j =0;

for (i=0;i<3;i++)

{

for (j=0;j<2;j++)

{

for (k=0;k<2;k++)

{

C[j] += A[k] * B[k][j];

}

}

cout<<C[j];

}

getch();

}

------------------------------------------------

was muss man nun noch dazu hacken? bzw wo ist der Fehler

danke

Also:

Um Arrays (Matrizen) addieren zu können müssen beide Arrays gleich groß sein... siehe Matrix (Mathematik) ? Wikipedia ...

müsstest also zur addition sowas hier machen (ist in C schnell getippt :P):

#include <stdio.h>

int main()

{

int A[3][2]={{3,2},{4,5},{2,1}};

int B[3][2]={{1,7},{5,9},{3,5}};

int C[3][2];

int i,j =0;

for (i=0;i<3;i++)

{

for (j=0;j<2;j++)

{

C[j] = A[j] + B[j];

printf("%02d ",C[j]);

}

printf("\n");

}

return 0;

}

das wäre eine Addition :D

Nur ein Tipp: Die Zwei Matrizen müssen nicht beide gleich Größ sein!!

Nur die Spalten bei der Ersten Matrize und die Zeilen bei der Zweiten Matrize müssen gleich sein.

Der Code zum Berechnen lautet wie folgt:



for(int x = 0; x < matrixA_line ; x++)				

      {

      for(int y = 0; y < matrixB_column ; y++)		

             {

             for(int z = 0; z < matrixB_line ; z++)				      {

                   size_matrixC[x][y] += size_matrixA[x][z] * size_matrixB[z][y];	

	       }

             }

      }

Bearbeitet von da-beauty

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.