online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/****************************************************************************** lambd1 = 0.1 N = 10000 def expa(lambd, N): import random import math xi = [] yi = [] sum = 0 sig = 0 for i in range(N): xi.append(random.random()) yi.append(-1/lambd * math.log(xi[i])) sum += yi[i] my = sum / N for i in range(N): sig = (yi[i] - my) ** 2 sig = sig / (N - 1) return yi *******************************************************************************/ #include <iostream> #include <cstdlib> #include <cmath> #include <ctime> using namespace std; double *expa(double *x, double lambda, int n) { double *y=new double[n]; int i; for (i=0; i<n; i++) { y[i]=(-1.0/lambda)*log(x[i]); } return y; } int main() { srand(time(0)); int n=1000; double *y =new double[n],*x = new double[n]; double ymax,ymin,dy,lambda=1.5; int i,k; int h[30]; for (i=0; i<n; i++) { x[i]=((double)rand() / (double)RAND_MAX); y[i]=(-1.0/lambda)*log(x[i]); } ymax=ymin=y[0]; for (i=1; i<n; i++) { if (y[i]>ymax) ymax=y[i]; if (y[i]<ymin) ymin=y[i]; } dy=(ymax-ymin)/30; for (i=0; i<30; i++) h[i]=0; for (i=0; i<n; i++) { k=(int)((y[i]-ymin)/dy); h[k]++; } for (i=0; i<30; i++) cout << ymin+i*dy << " " << h[i] << endl; delete [] y; delete [] x; return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue