LAB2: bounds-safe W reading
This commit is contained in:
12
src/LAB2.c
12
src/LAB2.c
@@ -15,9 +15,21 @@ void lab_2()
|
|||||||
printf("Enter [W_min]: ");
|
printf("Enter [W_min]: ");
|
||||||
READ_EXACT("%lf", w_min);
|
READ_EXACT("%lf", w_min);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
printf("Enter [W_max]: ");
|
printf("Enter [W_max]: ");
|
||||||
READ_EXACT("%lf", w_max);
|
READ_EXACT("%lf", w_max);
|
||||||
|
|
||||||
|
if (w_max < w_min)
|
||||||
|
{
|
||||||
|
printf("W_max cannot be less than W_min, try again\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (1);
|
||||||
|
|
||||||
printf("Enter [d]: ");
|
printf("Enter [d]: ");
|
||||||
READ_EXACT("%d", d);
|
READ_EXACT("%d", d);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user