www.pudn.com > 医学算法.rar > offset.c
#include#include char *table[] = { /* Valid parameters go here */ "if", "of", "n", 0 }; FILE *input = stdin; FILE *output = stdout; int n = 200; /* Number of detectors */ char *ifn = NULL; /* Input File name */ char *ofn = NULL; /* Output file name */ float buffer[2000]; int offset; /* Offset Detectors */ main(argc,argv) int argc; char **argv; { char cc; register int i,j; float new; while(argv++ , --argc){ if(**argv=='-' && argv[0][1])while(cc= *++*argv)switch(cc){ case 'o': offset = 1; break; default: fprintf(stderr,"bad flag: %c\n",cc); exit(1); }else switch(comm(*argv)){ case 1: /* if */ ifn = *argv+3; break; case 2: /* of */ ofn = *argv+3; break; case 3: /* n */ atoi(*argv + 2); break; } } if (ifn){ input = fopen(ifn,"r"); if (! input){ fprintf(stderr,"%s: Can't open %s for input.\n", argv[0], ifn); exit(1); } } if (ofn){ output = fopen(ofn,"w"); if (!output){ fprintf(stderr,"%s: Can't open %s for output.\n", argv[0], ofn); exit(1); } } while (fread(buffer,sizeof(float),n*4,input) == n*4){ buffer[n*4] = buffer[n*4-1]; if (offset) i = 1; else i = 0; for (j=0;j