#include #include #include #include #include #include #if 0 #undef assert #define assert(x) #endif #define xDEBUG 1 #define xDEBUGG 1 static int F[20000],FN; static int Best[20000]; int Width; static int lineeval(int start,int len) { int letters=0; int i; int mywidth,done; int r=0; int spacestot=0,spaceswant; for (i=0;i=33 && *s3<=126); #endif #if 1 assert(s2-s<=Width); #endif F[FN++]=s2-s; s=s2; while (*s==' ') s++; } } F[FN]=0; for (start=FN-1;start>=0;start--) { Best[start]=0; for (items=1;start+items<=FN;items++) { badness=lineeval(start,items); #ifdef DEBUG printf("pass: start=%d,items=%d: badness=%d\n",start,items,badness); #endif if (badness==-1) break; if (start+items < FN) badness+=Best[start+items]-1; if (!Best[start] || badness