Advertisement
Guest User

Untitled

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