Help i want to random numbers unrepeatedly | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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] << "; "; }

23rd Nov 2019, 5:35 AM
MIRZAEV KHAMIDULLO
MIRZAEV KHAMIDULLO - avatar
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.
23rd Nov 2019, 5:39 AM
Avinesh
Avinesh - avatar
0
Check the <random> (C++11 standard) header on cppreference website. Header function provide a lot of versatility.
24th Nov 2019, 10:43 AM
Іван Давидчук
Іван Давидчук - avatar