0
Help i want to random numbers unrepeatedly
#include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main () { int arr[10]{}, temp; srand(time(NULL)); arr[0]=rand()%10; cout << arr[0] << "; "; for (int i=1; i<10; i++) { arr[i]=rand()%10; for (int j=0; j<i; j++) { if (arr[i]==arr[j]) { arr[i]=rand()%10; j=0; } } //cout << arr[i] << "; "; }
2 Answers
+ 2
Хамидулло Мирзаев kindly copy your code and paste it in code playground and save it. Then you can share the link of the code here instead of writing the whole code in your description.
0
Check the <random> (C++11 standard) header on cppreference website. Header function provide a lot of versatility.