Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- using namespace std;
- int n;
- int main()
- {
- srand(time(NULL));
- int random;
- cin>>n;
- random = rand()%(n+1); //random between [0,n] , ((rand()%n)+1) between [1,n]
- cout<<random;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement