3 int *pelemente, *pmatrix1, *pmatrix2;
5 void read_matrix ( int *pzeilen, int *pspalten ) {
7 /* abfragen der anzahl der zeilen und spalten. eintrag auf pointer. */
8 int i,j,temp,zeilen,spalten;
9 printf("Anzahl der Zeilen eingeben: ");
12 printf("Anzahl der Spalten eingeben: ");
16 /* memory allocation */
17 pelemente=(int *)malloc(zeilen*spalten * sizeof(int));
19 /* abfragen der elemente */
20 for (i=0;i<zeilen;++i) {
21 for (j=0;j<spalten;++j) {
22 printf("Element: %d. Spalte und %d. Zeile: ",j+1,i+1);
24 /* speichern der elemente */
25 *(pelemente + i*spalten + j)=temp;
32 void write_matrix ( int zeilen, int spalten ) {
36 for (i=0;i<zeilen;++i) {
37 for (j=0;j<spalten;++j) {
38 temp=*(pelemente + i*spalten + j);
39 printf("%03d\t",temp);
53 printf("\nMatrixmultiplikation:\n\n");
59 /* save matrix1 for future use */
60 pmatrix1=(int *)malloc(z1*s1 * sizeof(int));
61 for (i=0;i<(s1*z1);++i) *(pmatrix1 + i)=*(pelemente + i);
70 /* save matrix2 for future use */
71 pmatrix2=(int *)malloc(z2*s2 * sizeof(int));
72 for (i=0;i<(s2*z2);++i) *(pmatrix2 + i)=*(pelemente + i);
77 /* just calculate if it is defined! */
79 printf("\n...well, i ll calculate it for you,\n\nestimated finish on the answer of the question of what life is all about:\t2323.Jan.15th\nand by the way, thanx for the fish. :)\n");
83 /* allocating memory for target matrix */
85 pelemente=(int *)malloc(z1*s2 * sizeof(int));
86 /* calculating matrix product */
90 for (k=0;k<s1;++k) ergebnis+=((*(pmatrix1 + i*s1 + k)) * (*(pmatrix2 + k*s2 + j)));
91 *(pelemente + i*s2 + j)=ergebnis;
96 /* printout target matrix */
97 printf("\n\nDie neue Matrix:\n\n");