Advertisement
luishh

matriz-1

May 16th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #define l 2
  3. #define c 2
  4. using namespace std;
  5. int main(){
  6.     int mat[l][c];
  7.     int lin,col,m=0;
  8.     cout<<"Informe os elementos 2 X 2: "<<endl;
  9.     //percorrendo matriz
  10.     for (lin=0; lin<l; lin++)
  11.      for (col=0;col<c; col++)
  12.       cin>>mat[lin][col];
  13.       cout<<endl;
  14.      
  15.       //procurando maior
  16.      for (lin=0; lin<l; lin++)  
  17.      for (col=0;col<c; col++)
  18.      if (mat[lin][col]>m)
  19.      m=mat[lin][col];
  20.      
  21.      //multipli
  22.      
  23.     //mostrando matriz e resultados
  24.     cout<<"Matriz original"<<endl;
  25.     cout<<endl<<endl;
  26.     for (lin=0; lin<l; lin++){
  27.      for (col=0;col<c; col++)  
  28.         cout<<mat[lin][col]<<"\t";
  29.     cout<<endl<<endl<<endl;
  30.         }
  31.         //mostrando soma
  32.     cout<<"Maior valor encontrado: "<<m<<endl;
  33.     cout<<endl<<endl;
  34.    
  35.     //mostrando matriz com soma
  36.      cout<<"Matriz X "<<m<<endl;
  37.      cout<<endl<<endl;
  38.      for (lin=0; lin<l; lin++)  {
  39.      for (col=0;col<c; col++)
  40.      cout<<((mat[lin][col])*m)<<"\t";
  41.      cout<<endl<<endl<<endl;
  42.     }
  43.  
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement