/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "diffint.p" */ #include /* differences between integers. Dr. Thomas D. Schneider National Institutes of Health National Cancer Institute Center for Cancer Research Nanobiology Program Molecular Information Theory Group Frederick, Maryland 21702-1201 toms@ncifcrf.gov permanent email: toms@alum.mit.edu http://www.ccrnp.ncifcrf.gov/~toms/ */ /* begin module version */ #define version 1.07 main(argc, argv) int argc; Char *argv[]; { /* of diffint.p 2007 Nov 29 2007 Nov 29, 1.07: rename difint as diffint 2007 Nov 28, 1.06: rename difint as diffint 1996 Oct 24, 1.05: functional 1986 dec 2, 1.00: origin */ /* end module version */ /* begin module describe.diffint */ /* name diffint: differences between integers synopsis diffint(input: in, output: out); files input: a set of integers, one per line. Lines that begin with "*" are ignored. output: the difference between each integer and 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 is given to the output. documentation see also {Program that allows selection of columns and ranges of differences to be selected:} diffintcut.p author Thomas Dana Schneider bugs technical notes The program originally acted as if the integer before the first one is zero, but this creates artifacts. The initial data point is now dropped. However, data often comes separate into chunks. This is marked by the comments. So the program resets everytime there is a comment line. The name was changed to diffint (from difint) because that's closer to the Unix diff command. bugs none known */ /* end module describe.diffint */ long current, previous; /* two integers from the input file */ boolean haveprevious = false; /* do we have the previous 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; scanf("%*[^\n]"); getchar(); putchar('\n'); continue; } scanf("%ld%*[^\n]", ¤t); getchar(); if (haveprevious) printf("%10ld\n", current - previous); haveprevious = true; previous = current; } exit(EXIT_SUCCESS); } /* End. */