Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- rm -f a.out
- gcc -x c - <<EOF
- #include <stdio.h>
- #include <stdint.h>
- unsigned long i;
- uint32_t prev_pid_time;
- #define LIMIT (300)
- unsigned long Gettime(void) { return i; }
- uint16_t f() {
- if(Gettime()>=prev_pid_time)
- return Gettime() - prev_pid_time;
- return LIMIT - prev_pid_time + Gettime();
- }
- #define valid(a,b,c) \
- i=b;prev_pid_time=a; \
- printf("f(%3i,%3i)=%4i", a,b,f()); \
- if(f()!=c) printf("<>%-3i - fail", c); \
- else printf("==%-3i", c); \
- printf("\n");
- int main() {
- valid( 0, 2, 2);
- valid( 2, 2, 0);
- valid( 3, 2, 299);
- valid(299, 2, 3);
- valid(295, 0, 5);
- return 0;
- }
- EOF
- ./a.out
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement