Added some safeguards.
This commit is contained in:
parent
2301be1637
commit
573343de8f
10
src/main.c
10
src/main.c
@ -12,10 +12,20 @@ int main(void) {
|
|||||||
printf("Enter \"min, max\": ");
|
printf("Enter \"min, max\": ");
|
||||||
scanf("%lf, %lf", &a, &b);
|
scanf("%lf, %lf", &a, &b);
|
||||||
|
|
||||||
|
if(a > b) {
|
||||||
|
fprintf(stderr, "`min' cannot be larger than `max'.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int parts;
|
unsigned int parts;
|
||||||
printf("Number of parts: ");
|
printf("Number of parts: ");
|
||||||
scanf("%u", &parts);
|
scanf("%u", &parts);
|
||||||
|
|
||||||
|
if(parts == 0) {
|
||||||
|
fprintf(stderr, "`parts' must at least be 1.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
double lRect, rRect, mRect, trap, simp;
|
double lRect, rRect, mRect, trap, simp;
|
||||||
lRect = rRect = mRect = trap = simp = 0;
|
lRect = rRect = mRect = trap = simp = 0;
|
||||||
for(unsigned int i = 0; i < parts; ++i) {
|
for(unsigned int i = 0; i < parts; ++i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user