1// this the c++ code for generating random numbers
2//pdf(x) = 1 if x>360
3// = 0 if x<0
4// = x/360 otherwise
5#include <iostream>
6#include <math.h>
7#include <stdlib.h>
8
9using namespace std;
10
11//This is a sample program to generate a random numbers based on probability desity function of spiner
12//pdf(x) = 1 if x>360
13// = 0 if x<0
14// = x/360 otherwise
15int N = 10;
16int main(int argc, char **argv)
17{
18 int p = 0;
19 for (int i = 0; i < N; i++)
20 {
21 p = rand() % 400;
22 if (p > 360)
23 cout << 0 << " ";
24 else if (p < 0)
25 cout << 0 << " ";
26 else
27 cout << p * 0.1 / 360 << " ";
28 }
29 cout << "...";
30}