Sign in with
Sign up | Sign in
Your question

Plz help me! matrices C++

Last response: in Applications
March 25, 2009 6:27:29 PM

please guys im desperate i have a homework from collage.. about matrices

1. Do a program that can do the subtraction of two-dimensional tables. (With creativity, the code is not look to the example). (code below, ex.)

2. Make a charming, creative, passionate and chulííísimmo program that performs the sum of two matrices, but this time using a three-dimensional formation, rather than three dimensional. The 1st cover a rate of 3 tables. The 2nd reference index row number, and the 3rd, the number of columns.

sorry for the crappy english.. this was all in spanish...

here an example of one the adds two matrices:

#include <stdio.h>
#include <math.h>
#define MAXFIL 20
#define MAXCOL 30

/ * Definition of symbolic constant indicating the maximum number of rows and columns * /

void leerentrada(int a[] [MAXCOL], int nfilas, int ncols);
void calcularsuma(int a[] [MAXCOL], int b[] [MAXCOL], int c[] [MAXCOL], int nfila, int ncols);
void escribirsalida(int c[] [MAXCOL], int nfilas, int ncols);

/ / Note that the functions were declared before the main, and that symbolic constants are always uppercase.

int nfilas, ncols;

printf("Cuantas filas ? ");
scanf("%d", &nfilas);
printf("Cuantas columnas ? ");
scanf("%d", &ncols);

printf("\n\nPrimera Tabla :\n");
leerentrada(a, nfilas, ncols);

printf("\n\nSegunda Tabla :\n");
leerentrada(b, nfilas, ncols);

calcularsuma(a, b, c, nfilas, ncols);

printf("\n\nSuma de los elementos :\n\n");
escribirsalida(c, nfilas, ncols);

/ * Read an entire table * /

void leerentrada(int a[] [MAXCOL], int m, int n)
/ * note that here the initial statements of defined functions do not end in a semicolon * /

int fila, col;
for (fila = 0; fila < m; ++fila)
printf("\nIntroducir datos para la fila No. %2d\n", fila + 1);

for (col = 0; col < n; ++col)
scanf("%d", &a[fila] [col] );
/ * Sum of the two tables of integers * /

void calcularsuma(int a[] [MAXCOL], int b[] [MAXCOL], int c[] [MAXCOL], int m, int n)
/ * No semicolon * /
int fila, col;
for (fila = 0; fila < m; ++fila)
for (col = 0; col < n; ++col)
c[fila] [col] = a[fila] [col] + b[fila] [col];

/ * Now, write the result of the sum of the table * /

void escribirsalida(int a[] [MAXCOL], int m, int n)
/ * No semicolon * /
int fila, col;
for (fila = 0; fila < m; ++fila)
for (col = 0; col < n; ++col)
printf("%4d", a[fila] [col]);


thats the one she gave as example

i need this by friday or im doomed!

More about : plz matrices

March 26, 2009 6:58:18 AM

ok i did no. 1 any help with no. 2
a b L Programming
April 24, 2009 3:41:13 PM

Can you put the code in [ code ] brackets and indent it properly? Would help a lot.
Related resources