#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

class random{
 int x;
public:
 random(void);
 int next();
 int nextinrange(int a, int b);
};

random::random(){
}


int random::next(){
 int srand((unsigned)time(0));
 x = rand();
 return x;
}

int random::nextinrange(int a, int b){
 int srand((unsigned)time(0));
 x = rand() % (a+1 - b) + b;
 return x;
}

int main(){
 int rand_max = 32767;
 random r;
 cout << "--0에서 " << rand_max << "까지의 랜덤 정수 10개--" << endl;
 for(int i=0; i<10; i++){
  int n = r.next();
  cout << n << ' ';
 }
 cout << endl << endl << "--2에서 " << "4 까지의 랜덤 정수 10개 --" << endl;
 for(int i=0; i<10; i++){
  int n = r.nextinrange(2, 4);
  cout << n << ' ';
 }
 cout << endl;
}

 

이거 랜덤 정수 10개 뽑는거랑

2부터 4까지 랜덤 정수 10개 뽑느건댕

컴파일은 되고 실행시켜보면 32767만 뜸...