fork download
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <stdlib.h>
  4.  
  5. int main() {
  6. srand(time(NULL));
  7. int a[3][3];
  8. int b[3][3];
  9. int resultado[3][3];
  10. int i,j,k;
  11. for (i=0;i<3;i++) {
  12. for (j=0;j<3;j++) {
  13. a[i][j] = (rand() % 3);
  14. b[i][j] = (rand() % 3);
  15. resultado[i][j]=0;
  16. }
  17. }
  18. for(i=0;i<3;i++){
  19. for(j=0;j<3;j++){
  20. for(k=0;k<3;k++){
  21. resultado[i][j] += a[i][k]*b[k][j];
  22. }
  23. }
  24. }
  25.  
  26. for(i=0;i<3;i++){
  27. for(j=0;j<3;j++){
  28. printf("%d ",resultado[i][j]);
  29. }
  30. printf("\n");
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
6 2 8 
2 0 8 
4 1 8