Advertisement
AnyaAS

Summa_strok_i_stolbcov

Jan 26th, 2015
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include "stdafx.h"
  2. void Print (int mas[][10], int height, int width)
  3. {
  4.     cout << "\t \tMassive" << endl;
  5.     for (int y = 0; y < height; y++)
  6.     {
  7.         int summa = 0;
  8.         for (int x = 0; x < width; x++)
  9.         {
  10.             mas[y][x] = rand() % 40;
  11.             cout.width(4);
  12.             cout << mas[y][x];
  13.             summa += mas[y][x];
  14.         }
  15.         cout << " | " << summa << endl;
  16.     }
  17.     cout << "_________________________________________" << endl;
  18.     for (int x = 0; x < width; x++)
  19.     {
  20.         int summa1 = 0;
  21.         for (int y = 0; y < height; y++)
  22.         {
  23.             summa1 += mas[y][x];
  24.         }
  25.         cout.width(4);
  26.         cout << summa1;
  27.     }
  28.     cout << endl;
  29. }
  30.  
  31. int _tmain(int argc, _TCHAR* argv[])
  32. {
  33.     srand(time(NULL));
  34.     const int height = 10;
  35.     const int width = 10;
  36.     int mas[height][width];
  37.     Print(mas, 10, 10);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement