Program mnozy macierze kwadratowe. <verbatim> #include<stdio.h> #include<math.h> #define N 3 main() { float A[N][N], B[N][N], C[N][N]; int i,j,k; printf("Podaj kolejne elementy macierzy A\n"); for (i=0; i<=N-1; ++i) { for (j=0; j<=N-1; ++j) { scanf("%f",&A[i][j]); } } printf("Podaj kolejne elementy macierzy B\n"); for (i=0; i<=N-1; ++i) { for (j=0; j<=N-1; ++j) { scanf("%f",&B[i][j]); } } /*mnozenie macierzy*/ for (i=0; i<=N-1; ++i) { for (j=0; j<=N-1; ++j) { C[i][j]=0; for (k=0; k<=N-1; ++k) { C[i][j]=C[i][j]+A[i][k]*B[k][j]; } } } printf("\nMacierz C\n\n"); for (i=0; i<=N-1; ++i) { for (j=0; j<=N-1; ++j) { printf("%8.3f",C[i][j]); } printf("\n"); } return 0; } </verbatim> -- Main.AgnieszkaB - 16 Mar 2005
This topic: Main
>
TWikiUsers
>
AgnieszkaB
>
MnozenieMacierzy
Topic revision:
16 Mar 2005,
AgnieszkaB
(raw view)
Copyright © CC-BY-SA by the contributing authors. All material on this collaboration platform is copyrighted under CC-BY-SA by the contributing authors unless otherwise noted.
Ideas, requests, problems regarding Foswiki?
Send feedback