Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4. int main() {
  5.     const int n = 4;
  6.     int array[n][n], y[n], res;
  7.     cout << "Enter array" << endl;
  8.     for (int i = 0; i < n; ++i)
  9.     {
  10.         for (int j = 0; j < n; ++j)
  11.         {
  12.             cout << "[" << i << "][" << j << "] = ";
  13.             cin >> array[i][j];
  14.         }
  15.     }
  16.     cout << "ur array" << endl;
  17.     for (int i = 0; i < n; ++i)
  18.     {
  19.         for (int j = 0; j < n; ++j)
  20.             cout << array[i][j] << " ";
  21.         cout << endl;
  22.  
  23.     }
  24.  
  25.     for (int i = 0; i < n; ++i)
  26.     {
  27.         res = 0;
  28.         for (int j = 0; j < n; ++j)
  29.         {
  30.             res += array[i][j];
  31.         }
  32.         y[i] = res;
  33.     }
  34.     for (int i = 0; i < n; ++i)
  35.         cout << "New array[" << i << "] = " << y[i] << endl;
  36.  
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement