online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <iostream> using namespace std; #define byte int #ifndef MF_len #define MF_len 5 #endif class MF { public: MF() { for(int i=0; i<MF_len; ++i){ data[i] = 0; index[i] = i+1; } } float update(float dummy) { byte i1 = 0; byte i2 = 0; bool FIO = 0; while((data[i1] < dummy) and (i1 < MF_len)) { if(index[i1] == 1) // skip first-in { FIO = 1; } else // shift forward { data[i2] = data[i1]; index[i2] = index[i1] - 1; ++i2; } ++i1; cout << i1<< ' '<<((i1 < MF_len)?' ':'!') << '<' << MF_len<< endl; //if(!(i1 < MF_len)){break;} } if(FIO) // first-in found. exit { cout << i2<< endl; data[i2] = dummy; index[i2] = MF_len; // new data point return data[MF_len>>1]; // return median } i1 = MF_len-1; byte i3 = i1; while(i1 >= i2) { if(index[i1] == 1) // skip first-in { FIO = 1; } else // shift backward { data[i3] = data[i1]; index[i3] = index[i1] - 1; --i3; } --i1; } cout << i2<< endl; data[i2] = dummy; index[i2] = MF_len; // first-in found. exit return data[MF_len>>1]; } friend ostream &operator << (ostream & out, const MF &mf) { for(int i=0; i<MF_len; ++i) { cout << mf.data[i] << ' '; } return out; } ~MF(){} private: float data[MF_len]; byte index[MF_len]; }; int main() { float v = 0; MF f; cout<<f<< f.update(100) << endl; cout<<f<< f.update(150) << endl; cout<<f<< f.update(550) << endl; cout<<f<< f.update(100000) << endl; cout<<f<< f.update(-1000) << endl; cout<<f<< f.update(190) << endl; cout<<f<< f.update(200) << endl; cout<<f<< f.update(130) << endl; cout<<f<< f.update(1000) << endl; cout<<f<< f.update(-240) << endl; cout<<f<< f.update(100) << endl; 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