online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> using namespace std; size_t alternateLength(int* a, size_t size, int first, int second) { for(size_t i=0; i < size; i++) if (a[i] == first) { size_t count = 0; size_t j = i; for(;;) { j++; count++; if (j>=size) j=0; //Дошли до конца? Начнем с начала if (i==j) return 0; //Сделали полный цикл => не нашли if (a[j]==second) return ++count; //Нашли второе - вернули } } return 0; } int main() { int WDOrder[] = {1, 2, 9, 5, 3, 6, 8}; int a,b; cout << "First:"; cin >> a; cout << "Second:"; cin >> b; cout << alternateLength(WDOrder, sizeof(WDOrder)/sizeof(WDOrder[0]), a, b); }

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