#include #include "postimes.out.h" quad_t postime(quad_t dist) { int i; if (dist <= postimes[0].dist) return postimes[0].time; if (dist > postimes[npostimes-1].dist) return postimes[npostimes-1].time; for (i = 0; i < npostimes-1; i++) if (dist <= postimes[i+1].dist) { return ((postimes[i+1].dist - dist) * postimes[i].time + (dist - postimes[i].dist) * postimes[i+1].time) / (postimes[i+1].dist - postimes[i].dist); } printf("boom!\n"); return 0; } int main(int argc, char *argv[]) { quad_t x[] = { -1, 0, 2, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000 }; int i; for (i = 0; i < sizeof(x)/sizeof(x[0]); i++) printf("%lld %lld\n", x[i], postime(x[i])); return 0; }