B3ar6

random - dzielniki

Sep 13th, 2020
790
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int x;
  9.     srand(time(NULL));
  10.     x = rand()%145+5;
  11.     cout << "Wylosowana liczba to: " << x << ", a jej dzielniki to: " << endl;
  12.    
  13.     for(int i=1; i<=x; i++)
  14.     {
  15.         if(x%i==0)
  16.         {
  17.             cout << i;
  18.            
  19.             if(i<x)
  20.                 cout << ", ";
  21.         }
  22.        
  23.     }
  24.     return 0;
  25. }
RAW Paste Data