online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include <cmath> #ifdef _WIN32 #include <intrin.h> uint64_t rdtsc(){ return __rdtsc(); } #else #include <x86intrin.h> uint64_t rdtsc(){ unsigned int lo,hi; __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); return ((uint64_t)hi << 32) | lo; } #endif using namespace std; float rnd1() { return fmod(1.0+sin(rdtsc())*0.5,1.0); } float rnd2() { return fmod(rdtsc()*0.004,1.0); } int main() { int a[40]={0,0,0,0,0,0,0,0,0,0}; for (int i=3000; i>0; i--) { int v = round(rnd1()*39); a[v]++; } int max=0; for (int i=39; i>=0; i--) if (a[i]>max) max=a[i]; cout<<"rnd1 distributions:\n\n"; for (int j=6; j>=0; j--) { for (int i=39; i>=0; i--) { if (a[i]*6.0/max<j) cout<<" "; else cout<<"0"; } cout<<"\n"; } cout<<"\nrnd1 values:\n\n"; for (int i=30; i>0; i--) { cout<<round(rnd1()*39)<<" "; } cout<<"\n\n"; for (int i=39; i>=0; i--) a[i]=0; for (int i=3000; i>0; i--) { int v = round(rnd2()*39); a[v]++; } max=0; for (int i=39; i>=0; i--) if (a[i]>max) max=a[i]; cout<<"\nrnd2 distributions:\n\n"; for (int j=6; j>=0; j--) { for (int i=39; i>=0; i--) { if (a[i]*6.0/max<j) cout<<" "; else cout<<"0"; } cout<<"\n"; } cout<<"\nrnd2 values:\n\n"; for (int i=30; i>0; i--) { cout<<round(rnd2()*39)<<" "; } cout<<"\n\n"; 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