Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <iostream>
- #include <stdio>
- #include <stdlib>
- #include <conio.h>
- #include <vcl.h>
- #include <math.h>
- #pragma hdrstop
- #define MAX 3
- //---------------------------------------------------------------------------
- #pragma argsused
- void wczytaj(int a[MAX][MAX])
- {
- for(int x=0;x<MAX;x++)
- {
- for(int z=0;z<MAX;z++)
- {
- printf("Podaj kolejna wartosc macierzy \n");
- scanf("%d",&a[x][z]);
- }
- }
- }
- void wypisz(int a[MAX][MAX])
- {
- for(int x=0;x<MAX;x++)
- {
- for(int z=0;z<MAX;z++)
- {
- printf("%d ",a[x][z]);
- }
- printf("\n");
- }
- }
- void dodaj(int a[MAX][MAX],int b[MAX][MAX],int c[MAX][MAX])
- {
- for(int x=0;x<MAX;x++)
- {
- for(int z=0;z<MAX;z++)
- {
- c[x][z]=a[x][z]+b[x][z];
- }
- }
- }
- void odejmij(int a[MAX][MAX],int b[MAX][MAX],int c[MAX][MAX])
- {
- for(int x=0;x<MAX;x++)
- {
- for(int z=0;z<MAX;z++)
- {
- c[x][z]=a[x][z]-b[x][z];
- }
- }
- }
- void transponuj(int a[MAX][MAX],int b[MAX][MAX])
- {
- for(int x=0;x<MAX;x++)
- {
- for(int z=0;z<MAX;z++)
- {
- b[x][z]=a[z][x];
- }
- }
- }
- void mnozenie(int a[MAX][MAX],int b[MAX][MAX],int c[MAX][MAX])
- {
- for(int x=0;x<MAX;x++)
- {
- for(int z=0;z<MAX;z++)
- {
- int suma;
- suma=0;
- for( int l=0;l<MAX;l++)
- {
- suma=suma+a[x][z]*b[x][z];
- }
- c[x][z]=suma;
- }
- }
- }
- int main(int argc, char* argv[])
- {
- int a[MAX][MAX];
- int b[MAX][MAX];
- int c[MAX][MAX];
- wczytaj(a);
- wczytaj(b);
- wypisz(a);
- dodaj(a,b,c);
- printf("wynik dodawania to: \n");
- wypisz(c);
- odejmij(a,b,c);
- printf("wynik odejmowania to: \n");
- wypisz(c);
- transponuj(a,b);
- printf("Macierz po transpozycji \n");
- wypisz(b);
- mnozenie(a,b,c);
- printf("Macierz po mnozeniu \n");
- wypisz(c);
- getch();
- return 0;
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement