#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
class Random {
public:
static void seed() {
srand((unsigned)time(NULL));
}
static int nextInt(int min = 0, int max = 32767);
};
//rand() 랜덤한 정수 발생
int Random::nextInt(int min, int max) {
int nextInt = rand() % 100 + 1;
return 0;
}
int main() {
Random::seed();
cout << "1에서 100까지 랜덤한 정수를 10개 출력합니다" << endl;
for (int i = 0; i < 10; i++) cout << Random::nextInt(1, 100) << ' ';
cout << endl;
return 0;
}
-------------------------------------------
이렇게 코드 짜놓고
돌렸는데
0 0 0 0 0 0 0 0 0 0
만 계속 출력되는게 어디서 잘못한건지 감이 안잡힘 어디가 문제일까?
4개의 댓글
무분별한 사용은 차단될 수 있습니다.
우리힘내요
랜덤함에서 왜 0을 리턴함
년째 긴하품
나도 글적고 눈치챘다 ㅋㅋㅋ 고맙고맙
년째 긴하품
해결했읍니다 ㅎㅎ
잉텔
std::mt19937 씁시다