Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <math.h>
- /*
- void vypis(int mat,int p,int q)
- {
- if(p!=q)
- {
- printf("%d\t",mat);
- }
- else
- {
- printf("%d\n",mat);
- }
- }
- */
- int main(int argc, char **argv)
- {
- int a,b,c,x,y,z;
- printf("Maximalni rozmeri matice muzou byt 10x10 !!!\n");
- printf("Zadej pocet radku matice A \n");
- scanf("%d",&a); //a-řádky A
- printf("Zadej pocet sloupcu matice A \n");
- scanf("%d",&b); //b-sloupce A
- printf("Zadej pocet sloupcu B \n");
- scanf("%d",&c);
- int matA[10][10];
- int matB[10][10];
- int matC[10][10];
- srand(time(0));
- printf("Matice 1\n");
- if(a<10&&b<10)
- {
- for(x=0;x<a;x++)
- {
- for(y=0;y<b;y++)
- {
- matA[x][y]= rand() %10;
- printf("%i\t",matA[x][y]);
- }
- printf("\n");
- }
- }
- printf("\nMatice 2\n");
- if(a<10&&b<10)
- {
- for(x=0;x<a;x++)
- {
- for(y=0;y<b;y++)
- {
- matB[x][y]= rand() %10;
- printf("%i\t",matA[x][y]);
- }
- printf("\n");
- }
- }
- printf("Soucin je:\n");
- if (matA!=NULL&&matB!=NULL)
- {
- for (x=0; x<=(a-1);x++) /* opakuj pro všechny řádky v A */
- {
- for (y=0; y<=(b-1);y++) /* opakuj pro všechny sloupce v B */
- {
- for (z=0; z<=(c-1); z++)
- {
- matC[x][y]=matC[x][y]+(matA[x][z]*matB[z][x]); /* pronásob vektor i-tého řádku matice A */
- printf("%i\t",matC[x][y]);
- /* s vektorem j-tého sloupce matice B*/
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement