Advertisement
CLazStudio

q198996552

Mar 14th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <iomanip>
  4. #include <time.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     srand(time(NULL));
  11.  
  12.     int arr[20][20];
  13.  
  14.     int positiveCount = 0;
  15.     int negativeCount = 0;
  16.  
  17.     for (int i = 0; i < 20; i++)
  18.     {
  19.         for (int j = 0; j < 20; j++)
  20.         {
  21.             arr[i][j] = rand()%198 - 99;
  22.  
  23.             //cout << "arr[" << i <<"][" << j << "] = ";
  24.             //cin >> arr[i][j];
  25.             cout << setw(4) << arr[i][j];
  26.  
  27.             if (arr[i][j] > 0)
  28.                 positiveCount++;
  29.             else if (arr[i][j] < 0)
  30.                 negativeCount++;
  31.         }
  32.         cout << endl;
  33.     }
  34.  
  35.     cout << (positiveCount - negativeCount) << endl;
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement