Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <stdlib.h>
  4. using namespace std;
  5.  
  6. int main(){
  7. int n,m;
  8. srand(time(NULL));
  9. cin>>n>>m;
  10. int mat1[n][m];
  11. int mat2[n][m];
  12. for(int i=0;i<n;i++){
  13. for(int j=0;j<m;j++){
  14. mat1[i][j]=rand()%100;
  15. mat2[i][j]=rand()%100;
  16. }
  17. }
  18.  
  19. cout << "macierz 1: \n";
  20. for(int i=0;i<n;i++){
  21. for(int j=0;j<m;j++){
  22. cout << mat1[i][j] << " ";
  23. }
  24. cout << endl;
  25. }
  26.  
  27. cout << "macierz 2: \n";
  28. for(int i=0;i<n;i++){
  29. for(int j=0;j<m;j++){
  30. cout << mat2[i][j] << " ";
  31. }
  32. cout << endl;
  33. }
  34.  
  35. cout << "Suma: \n";
  36. for(int i=0;i<n;i++){
  37. for(int j=0;j<m;j++){
  38. mat1[i][j]=mat1[i][j]+mat2[i][j];
  39. cout<<mat1[i][j] << " ";
  40. }
  41. cout << endl;
  42. }
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement