令人蛋疼的walkthrough,疑问在comments里,请指点,谢谢。
#include <stdio.h>#define MIN 2
#define MAX 5
int pRbar ( double area, int *size, int *no );
int main() {
int s, n, i;
double area, cc;
area = 15.00;
while ( area <= 105.00) {
i = pRbar ( area, &s, &n );
if ( i == 1 )
printf("To get %.0lf, use %d-#%d\n", area, n, s );
else
printf("No match found\n");
area += 15.00;
}
return 0;
}
int pRbar ( double area, int *size, int *no ) {
int i, j, k;
double a;
k = 1;
for ( j = MIN; j <= MAX && k; j++ ) //j <= MAX && k不就是j<=5&&1,这不是自相矛盾吗?
{
for ( i = 1; i <= 4 && k; i++ )//疑问和上一个一样
{
switch ( i ) {
case 1:
a = 7.50;
break;
case 2:
a = 11.50;
break;
case 3:
a = 15.25;
break;
case 4:
a = 19.05;
break;
}
if (a * j >= area) {
k = 0;
*size = i;
*no = j;
}
}
}
printf("(%d-#%d %5.2lf)\n", j-1, i-1, a);
return !k;//除了k之外其他都输出吗?
}