#include "stdio.h" #include "stdlib.h" unsigned min(unsigned a, unsigned b) { return a=0 && ee<=Emax) f[k+1][ee]=min(f[k+1][ee],f[k][e]+x*c[k]+ee*t[k]); for(ee=0,k=n;k--;printf("%2d %2d=%2d+%2d*%2d+%2d*%2d %2d=%2d+%2d-%2d\n",k,f[k+1][ee],f[k][e],x,c[k],ee,t[k],ee,e,x,d[k]),ee=e) for(x=0;x<=q[k];x++) if(e=ee-x+d[k],e>=0) if(f[k+1][ee]==f[k][e]+x*c[k]+ee*t[k]) break; return f[n][0]; } int main(int argc, char const *argv[]) { int n = 6; int d[] = { 5, 6, 6, 4, 5, 7}; int q[] = {10, 10, 10, 10, 10, 10}; int c[] = { 3, 1, 2, 3, 1, 5}; int t[] = { 2, 2, 1, 2, 2, 10}; int cout = cout_min(n, d, q, t, c); printf("Cout min %d\n", cout); return 0; }