Polnochniy

Untitled

Nov 11th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <time.h>
  4. using namespace std;
  5. const int N = 5;
  6. int main()
  7. {
  8. setlocale(LC_ALL, "Rus");
  9. int a[N];
  10. int numb;
  11. srand(time(0));
  12. cout << "Введите цифру для разной генерации случайных чисел: ";
  13. cin >> numb;
  14. if (numb == 1)
  15. {
  16. for (int i = 0; i < N; i++)
  17. {
  18. a[i] = rand();
  19. cout << a[i] << endl;
  20. }
  21. }
  22. else if(numb ==2)
  23. {
  24. for (int i = 0; i < N; i++)
  25. {
  26. a[i] = 50*rand()-25;
  27. cout << a[i] << endl;
  28. }
  29. }
  30. else if (numb == 3)
  31. {
  32. for (int i = 0; i < N; i++)
  33. {
  34. a[i] = 2* rand() - 25/2;
  35. cout << a[i] << endl;
  36. }
  37. }
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment