Advertisement
Schknheit

Matrix

Dec 19th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(int argc, char *argv[]){
  6.    
  7.     int i, j, s_i = 0, s_p = 0, q_p = 0, q_i = 0, mat[2][2];
  8.    
  9.     cout << "Please four inputs: " << endl;
  10.    
  11.     for(i = 0; i < 2; i++){
  12.         for(j = 0; j < 2; j++){
  13.             cin >> mat[i][j];
  14.                 if(mat[i][j] % 2 == 0){
  15.                     q_p = q_p + 1;
  16.                 }
  17.                 else{
  18.                     q_i = q_i + 1;
  19.                 }
  20.         }
  21.     }
  22.    
  23.     cout << "\n" << endl;
  24.    
  25.     for(i = 0; i < 2; i++){
  26.         for(j = 0; j < 2; j++){
  27.             if(mat[i][j] % 2 == 0){
  28.                 s_p = s_p + mat[i][j];
  29.             }
  30.             else{
  31.                 s_i = s_i + mat[i][j];
  32.             }  
  33.         }
  34.     }
  35.    
  36.     if(mat[i] == mat[j]){
  37.             cout << "i = j" << endl;
  38.         }
  39.         else{
  40.             cout << "i != j" << endl;
  41.         }
  42.    
  43.     cout << "Even sum: " << s_p << endl;
  44.     cout << "Odd sum: " << s_i << endl;
  45.     cout << "Even amount: " << q_p << endl;
  46.     cout << "Odd amount: " << q_i << endl;
  47.    
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement