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...
/ * 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("\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();
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
Reply to Zenthar
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.