/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "difint.p" */ #include /* differences between integers. tom schneider */ /* begin module version */ #define version 1.05 main(argc, argv) int argc; Char *argv[]; { /* of difint.p 1996 October 24 origin 1986 dec 2 */ /* end module version */ /* begin module describe.difint */ /* name difint: differences between integers synopsis difint(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. author Thomas Dana Schneider 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. bugs none known */ /* end module describe.difint */ 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. */