Created
March 1, 2018 19:45
-
-
Save paulo-raca/c41c4aaa5d7152644ef04a534749471e to your computer and use it in GitHub Desktop.
Seach for data on an array region with decreasing step sizes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <inttypes.h> | |
#include <stdlib.h> | |
void scan(uint64_t min, uint64_t max, uint64_t min_step = 1) { | |
uint64_t step = 1L<<63; | |
printf("%02" PRIu64 "\n", min); | |
while (step > min_step) { | |
for (uint64_t i = min + step / 2; i<max; i+=step) { | |
printf("%03" PRIu64 "\n", i); | |
} | |
printf("\n"); | |
step /= 2; | |
} | |
} | |
int main(int argc, char** argv) { | |
if (argc != 3 && argc != 4) { | |
printf("Usage: %s MIN MAX [MIN_STEP]\n", argv[0]); | |
return 1; | |
} | |
scan(atoi(argv[1]), atoi(argv[2]), argc == 3 ? 1 : atoi(argv[3])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment