Writing a program to input numbers 1 to 100 randomly without repeating?
Last edited on
Did you mean 'output numbers from 1 to 100?'
Do you mean like this?
1 2 3 4 5 6 7 8 9
|
#include <iostream>
#include <ctime>
using namespace std;
int main(){
srand(time(0));
for(int i = 0; i < 100; i++){
cout << 1+(rand()%100) << ",";
}
}
|
Last edited on
Use srand(int(NULL)) to get the random numbers, vectors or array to store used numbers, and a few nested loops.