0

I have number form 1-42 I want to let C++ shuffle number for me, I have number form 1-42 and I used code below :

#include <iostream>
#include <algorithm>

using namespace std;
int main()
{
int S[42]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42};
random_shuffle(&S[1], &S[42]);
cout<<S[42];
}

It's working, but the problem is every times i run it, it always show number 3 all the time, I think there is something wrong, Please help;

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Hengly
  • 121
  • 1
  • 5

0 Answers0