일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- code=0)
- 이더리움
- 자소서 빨리 쓰는 법
- mac hadoop
- mac hadoop 설치
- mac hive 3
- 카카오 2020 코딩테스트
- 자소서 시간 줄이기
- hadoop safe mode leave
- Safe mode is ON
- mac hadoop 설정
- 기업 조사 빨리 하는 법
- 카카오 자물쇠와 열쇠
- 이더리움 #ethereum
- Could not open client transport with JDBC Uri: jdbc:hive2://localhost:10000
- mac hive
- 도커 교과서
- mac hadoop 3
- hive beeline
- is not allowed to impersonate hive (state=08S01
- 자소서 빨리
- hive beeline 에러
- 백준 18428
- hadoop safe mode
- Failed to connect to localhost:10000
- hive beeline 실행
- 자소서 너무 오래 걸림
- 카카오 2020 코테
- hive beeline 설정
- Resources are low on NN
Archives
- Today
- Total
A seeker after truth
sololearn C++ tutorial: Functions 배운 내용 메모 본문
<Random function>
you can access a pseudo random number generator function that's called rand().
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
cout << rand();
}
Use the modulo (%) operator to generate random numbers within a specific range.
The example below generates whole numbers within a range of 1 to 6.
int main () {
for (int x = 1; x <= 10; x++) {
cout << 1 + (rand() % 6) << endl;
}
}
/* Output:
6
6
5
5
6
5
1
1
5
3
*/
srand()는 seed값 줘서 다른 인스턴스 혹은 세트를 만드는 느낌이라는 것 이미 이해했지? 혹시 잊으면 검색해서 다시 공부하면 되고.
보통 시드로 time값 준다는건 알 것이고.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main () {
srand(time(0));
for (int x = 1; x <= 10; x++) {
cout << 1 + (rand() % 6) << endl;
}
}
time(0) will return the current second count, prompting the srand() function to set a different seed for the rand() function each time the program runs.
call by value시, a copy of the argument is passed to the function, the original argument is not modified by the function.
'Programming Language > C++' 카테고리의 다른 글
Templates, Exceptions, and Files (0) | 2019.11.26 |
---|---|
Sololearn C++ Tutorial 배운 내용 메모: Inheritance & Polymorphism (0) | 2019.11.23 |
sololearn C++ More On Classes 배운 내용 메모 (0) | 2019.11.18 |
sololearn c++ tutorial: Pointers 배운 내용 메모 (0) | 2019.11.14 |
sololearn c++ tutorial: Basic Concepts 배운 내용 메모 (0) | 2019.11.04 |