Haval1

Question 1

Jan 19th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include"stdafx.h"
  2. #include <iostream>
  3. /*
  4. find the sum of second col and sub the sum from second diagonal item array size a[3][3]
  5. */
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int i, j, a[3][3], sum = 0;
  11.     for (size_t i = 0; i < 3; i++)
  12.     {
  13.         for (size_t j = 0; j < 3; j++)
  14.         {
  15.             cin >> a[i][j];
  16.         }
  17.     }
  18.     for (size_t i = 0; i < 3; i++)
  19.     {
  20.         sum += a[i][1];
  21.     }
  22.     for (size_t i = 0; i < 3; i++)
  23.     {
  24.         for (size_t j = 0; j < 3; j++)
  25.         {
  26.             a[i][j] = sum - a[i][2 - i];
  27.         }
  28.     }
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment