Tom's Hardware > Forum > Applications > Programming > Plz help me! matrices C++

Plz help me! matrices C++

Forum Applications : Programming - Plz help me! matrices C++

Tom's Hardware: Over 1.4 million members in 6 different countries available to answer all your high-tech questions. Sign up now! Its free!
Word :    Username :           
 

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<conio.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.

main()
{
int nfilas, ncols;
int a[MAXFIL] [MAXCOL], b[MAXFIL] [MAXCOL], c[MAXFIL] [MAXCOL];

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] );
}
return;
}
/ * 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];
return;
}

/ * 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]);
printf("\n" );
}
getch();

}

thats the one she gave as example

i need this by friday or im doomed!

Sponsored Links
Register or log in to remove.

ok i did no. 1 any help with no. 2

Reply to antmiu2

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

------------------------------ The capacity to learn is a gift; The ability to learn is a skill; The willingness to learn is a choice. - Rebec of Ginaz
http://valid.canardpc.com/cache/banner/600609.png
Reply to Zenthar
Tom's Hardware > Forum > Applications > Programming > Plz help me! matrices C++
Go to:

There are 1122 identified and unidentified users. To see the list of identified users, Click here.

Please mind

You are about to answer a thread that has been inactive for more than 6 months.
If you still wish to proceed, please ensure that your posting is original and does not duplicate or overlap any prior responses to this thread.

Add a reply Cancel
Sponsored links
  • Ask the community now
  • Publish
Ad
They won a badge
Join us in greeting them