Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1.   1 #include <stdio.h>
  2.   2 #include <stdbool.h>
  3.   3 #include <stdlib.h>
  4.   4 #include <assert.h>
  5.   5
  6.   6 struct Range {
  7.   7         int low;
  8.   8         int high;
  9.   9 };
  10.  10
  11.  11 typedef struct Range range;
  12.  12
  13.  13 //input should be an int array with num empty cells
  14.  14 //limits should be an array with the size num, while cell i has the range corresponding to the i    -th input
  15.  15
  16.  16 void input_numbers_within_range(int* input, int num, range* limits) {
  17.  17         bool isInputOk = true;
  18.  18         do {
  19.  19                 for(int i = 0,x; i < num; ++i) {
  20.  20                         scanf("%d",&x);
  21.  21                         if(!(limits[i].low <= x && x <= limits[i].high)) {
  22.  22                                 printf("Input not in range\n");
  23.  23                                 isInputOk = false;
  24.                                                                                   1,18          Top
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement