/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "doudiff.p" */ #include /* double differences between integers. Dr. Thomas D. Schneider National Cancer Institute Laboratory of Experimental and Computational Biology Frederick, Maryland 21702-1201 toms@ncifcrf.gov permanent email: toms@alum.mit.edu (use only if first address fails) http://www.lecb.ncifcrf.gov/~toms/ */ /* begin module version */ #define version 1.00 main(argc, argv) int argc; Char *argv[]; { /* of doudiff.p 2003 Aug 24 2003 Aug 24, 1.00, origin from difint */ /* end module version */ /* begin module describe.doudiff */ /* name doudiff: double differences between integers synopsis doudiff(input: in, output: out); files input: a set of integers, one per line. Lines that begin with "*" are ignored. output: Two integers are written per line: the difference between each integer and the previous one. the difference between each integer and the one before the previous one. describe Lines that begin with an asterisk ('*') are first copied to the output. then the difference between each integer in input and the previous one along with the double distance difference is given to the output. author Thomas Dana Schneider technical notes The initial data points cannot be used. Data often comes separate into chunks. This is marked by the comments. So the program resets everytime there is a comment line. bugs none known */ /* end module describe.doudiff */ long current, previous; /* two integers from the input file */ boolean haveprevious = false; /* do we have the previous value? */ long PREprevious; /* three integers from the input file */ boolean havePREprevious = false; /* do we have the PREprevious value? */ PASCAL_MAIN(argc, argv); while (!P_eof(stdin)) { if (P_peek(stdin) == '*') { /* copy lines beginning with '*' to output */ while (!P_eoln(stdin)) { putchar(P_peek(stdin)); getc(stdin); } haveprevious = false; /* this resets at the '*' comments */ havePREprevious = false; /* this resets at the '*' comments */ scanf("%*[^\n]"); getchar(); putchar('\n'); continue; } scanf("%ld%*[^\n]", ¤t); getchar(); /* if haveprevious then writeln(output,current-previous:10); */ if (havePREprevious) printf("%ld %ld\n", current - previous, current - PREprevious); /* for the next data point: */ if (haveprevious) { havePREprevious = true; PREprevious = previous; } haveprevious = true; previous = current; } exit(EXIT_SUCCESS); } /* End. */