online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #define N 3 #define INFINITY 1000000000 int p[N] = {3, 6, 4}; int s[N] = {2, 3, 7}; int cost(int i, int t){ printf ("%*c inizio cost con i = %d, t = %d \n", N-i, ' ', i, t); if (t <= 0) { printf("%*c t <= 0, return 0 \n", N-i, ' '); return 0; } if (i < 0) { printf("%*c i < 0, return inf \n", N-i, ' '); return INFINITY; } int a, b; printf("%*c chiamo cost con scelta giocatore \n", N-i, ' '); a = p[i] + cost(i - 1, t - s[i]); printf("%*c totale costo con scelta giocatore: %d \n", N-i, ' ', a); printf("%*c chiamo cost senza scelta giocatore \n", N-i, ' '); b = cost(i - 1, t); printf("%*c totale costo senza scelta giocatore: %d \n", N-i, ' ', a); if (a < b) { printf("%*c return a: %d\n", N-i, ' ', a); return a; } else { printf("%*c return b: %d\n", N-i, ' ', b); return b; } } int main() { int c; c = cost(2, 5); printf("costo minimo: %d\n", c); 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