Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <math.h>
  4. #include <cstdlib>
  5. #include <ctime>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. int a,b;
  12. float n,c,srednia;
  13. srand( time( NULL ) );
  14. cout<<"Podaj ilosc liczb: ";
  15. cin>>n;
  16. cout<<"Podaj poczatek przedzialu: ";
  17. cin>>a;
  18. cout<<"Podaj koniec przedzialu: ";
  19. cin>>b;
  20. int los;
  21. for (int i=0;i<n;i++)
  22. {
  23. los=rand()%(b-a)+a;
  24. cout<<los<<" "<<endl;
  25. c=c+los;
  26. }
  27. srednia=c/n;
  28. cout<<"suma liczb: "<<c<<endl;
  29. cout<<"srednia liczb: "<<srednia<<endl;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement