Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <stdlib.h>
- using namespace std;
- int main(){
- int n,m;
- srand(time(NULL));
- cin>>n>>m;
- int mat1[n][m];
- int mat2[n][m];
- for(int i=0;i<n;i++){
- for(int j=0;j<m;j++){
- mat1[i][j]=rand()%100;
- mat2[i][j]=rand()%100;
- }
- }
- cout << "macierz 1: \n";
- for(int i=0;i<n;i++){
- for(int j=0;j<m;j++){
- cout << mat1[i][j] << " ";
- }
- cout << endl;
- }
- cout << "macierz 2: \n";
- for(int i=0;i<n;i++){
- for(int j=0;j<m;j++){
- cout << mat2[i][j] << " ";
- }
- cout << endl;
- }
- cout << "Suma: \n";
- for(int i=0;i<n;i++){
- for(int j=0;j<m;j++){
- mat1[i][j]=mat1[i][j]+mat2[i][j];
- cout<<mat1[i][j] << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement