rootuss

3.22

Dec 16th, 2016
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6.  
  7.  
  8.  
  9. int main()
  10. {
  11.     cout << "losuje liczbe" << endl;
  12.     double T[10];
  13.     srand(time(NULL));
  14.     double suma=0,iloczyn=1;
  15.     for (int i=0; i<10; i++)
  16.     {
  17.         T[i]=-10+(double)rand()/RAND_MAX*(33);
  18.  
  19.     suma=suma+T[i];
  20.     if (T[i]<6)
  21.     {
  22.      iloczyn=T[i]*iloczyn;
  23.     }
  24.     }
  25.     cout<<"suma: "<<suma<<endl;
  26.     cout<<"iloczyn: "<<iloczyn<<endl;
  27.  
  28.     return 0;
  29. }
Add Comment
Please, Sign In to add comment