/* Problem 9--Making Book This was a very easy problem. The only thing you had to notice was that A might be greater than B; the problem never stated otherwise.*/ #include #include int main (int argc, char **argv); int main (int argc, char **argv) { FILE *in, *out; int ct[10], A, B, t, P, cs; in = fopen ("prob9.in","r"); out = fopen ("prob9.out","w"); for (cs=1;fscanf (in,"%d",&A),A > 0;cs++) { fscanf (in,"%d",&B); if (A > B) { /* Are A and B out of order? */ t = A; A = B; B = t; } t = 0; /* Initialize array */ for (t=0;t<10;t++) ct[t] = 0; for (t=A;t<=B;t++) /* We pull off the ones digit of each number */ for (P=t;P>0;P/=10) /* and divide it by 10 */ ct[P%10]++; fprintf (out,"Case %d: ",cs); for (t=0;t<10;t++) /* Print answer */ fprintf (out,"%d:%d ",t,ct[t]); fprintf (out,"\n"); } fclose (in); fclose (out); return EXIT_SUCCESS; }