Guest User

Untitled

a guest
Jan 4th, 2018
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. // ConsoleApplication1.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include <iostream>
  5. #include <cstdio>
  6. #include <stdlib.h>
  7. #include <time.h>
  8.  
  9.  
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15. int n,z,x;
  16. cout << "Podaj liczbe elemtow do wylosowania: ";
  17. cin >>n;
  18.  
  19. cout << endl << "Podaj zakres losowanie od jakiej liczby ma byc losowane: ";
  20. cout << endl << "z: ";
  21. cin >> z;
  22. cout << endl << "x: ";
  23. cin >> x;
  24.  
  25. int* tablica = new int[n]; // deklaracja tablicy o rozmiarze n
  26.  
  27. for(int i = 0; i < n; i++)
  28. {
  29. tablica[i] = (rand() % x) + z; // wpisywanie do tablicy
  30. }
  31.  
  32. for(int i = 0; i < n; i++)
  33. {
  34. cout << tablica[i] << " || "; // wyswietlenie
  35. }
  36.  
  37. delete tablica; // zwolnienie pamieci
  38.  
  39. getchar();
  40. getchar();
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment