Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main(){
- int x[10][10], y[10][10], z[10][10];
- int i, j, M, N;
- cout<<"Unijeti dimezije matrice X koje su ujedno i dimenzije matrice Y: "<<endl;
- do{
- cout<<"broj redova: "; cin>>N;
- cout<<"broj kolona: "; cin>>M;
- } while((N>10)||(M>10));
- cout<<endl;
- cout<<"unestite elemente X matrice: "<<endl;
- for(int i=0; i<N; i++){
- cout<<endl<<"unesite elemente niza: "<<endl;
- for(int j=0; j<M; j++){
- cout<<"x["<<i<<"]["<<j<<"]= ";
- cin>>x[i][j];
- }
- }
- cout<<endl;
- cout<<"unestite elemente Y matrice: "<<endl;
- for(int i=0; i<N; i++){
- cout<<endl<<"unesite elemente niza: "<<endl;
- for(int j=0; j<M; j++){
- cout<<"y["<<i<<"]["<<j<<"]= ";
- cin>>y[i][j];
- }
- }
- cout<<endl;
- //ispis matrica X i Y
- cout<<"Matrica X: "<<endl;
- for(int i=0; i<N; i++){
- for(int j=0; j<M; j++){
- cout<<setw(5)<<x[i][j];
- } cout<<endl;
- }
- cout<<endl;
- cout<<"unijeli ste matricu Y: "<<endl;
- for(int i=0; i<N; i++){
- for(int j=0; j<M; j++){
- cout<<setw(5)<<y[i][j];
- } cout<<endl;
- }
- cout<<endl;
- //X+Y
- cout<<"zbir matrica X i Y je:"<<endl;
- for(int i=0; i<N; i++){
- for(int j=0; j<M; j++){
- cout<<setw(5)<<x[i][j]+y[i][j];
- }cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement