Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.    
  9.     srand(time(NULL));
  10.    
  11.     float tab[6][4];
  12.     // Tworzenie tablicy
  13.     for (int i = 0; i< 6;i++){
  14.         for (int j = 0; j< 4;j++) {
  15.             float los = -2 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(6+2)));
  16.             tab[i][j] = los;
  17.         }
  18.     }
  19.     // 1.
  20.     for (int i = 0; i< 6;i++){
  21.         for (int j = 0; j< 4;j++) {
  22.             cout << tab[i][j] << " ";
  23.         }
  24.         cout << "\n";
  25.     }
  26.     // 2.
  27.     float ilo = 1;
  28.     for (int i = 0; i< 6;i++){
  29.         for (int j = 0; j< 4;j++) {
  30.             if (j % 2 == 0) {
  31.                 ilo *= tab[i][j];
  32.             }
  33.         }
  34.     }
  35.     cout << ilo << "\n";
  36.    
  37.     // 3.
  38.     int mniejszeOdDwa = 0;
  39.     for (int i = 0; i< 6;i++){
  40.         for (int j = 0; j< 4;j++) {
  41.             if (tab[i][j] < 2) {
  42.                 mniejszeOdDwa++;
  43.             }
  44.         }
  45.     }
  46.     cout << mniejszeOdDwa << "\n";
  47.    
  48.     // 4. za trdudne
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement