online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ //活动安排问题:start[i]={0,1,3,0,5,3,5,6,8,8,2,12},finish[i]={0,4,5,6,7,8,9,10,11,12,13,14} #define maxsize 12 #include <iostream> using namespace std; int n=11; int x[maxsize]={0}; //用来判断活动是否被选 int start[maxsize]={0,1,3,0,5,3,5,6,8,8,2,12}; //各个活动开始时间,0号元素不用 int finish[maxsize]={0,4,5,6,7,8,9,10,11,12,13,14}; //各个活动的结束时间,0号元素不用 void GreedySelect() { int i = 1, j = 1; x[1] = 1; for(i = 2; i <= n; i++){ if(start[i] > finish[j]){ x[i] = 1; j = i; } } } int main() { GreedySelect(); for(int i = 1; i <= n; i++){ if(x[i] == 1){ cout << start[i] << "," << finish[i] << 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