Advertisement
Bertran_rz

Untitled

Sep 8th, 2021
1,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int const size = 10;
  9.    
  10.     int arr[size][size];
  11.  
  12.     int oneCount = 0;
  13.  
  14.     for(int i = 0; i < size; i++)
  15.     {
  16.         for(int j = 0; j < size; j++)
  17.         {
  18.             arr[i][j] = 0;
  19.         }
  20.     }
  21.    
  22.     for(int i = 0; i < 4; i++)
  23.     {
  24.         int x = rand()%10;
  25.         int y = rand()%10;
  26.        
  27.         if (arr[x][y] == 0)
  28.             arr[x][y] = 1;
  29.         else
  30.             i--;
  31.     }
  32.  
  33.     for(int i = 0; i < size; i++)
  34.     {
  35.         for(int j = 0; j < size; j++)
  36.             cout << arr[i][j] << " " ;
  37.     }
  38.     cout << endl;
  39. }
  40.  
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement