|
|
1.1 ! root 1: #include <stdio.h> ! 2: float fract = 2; ! 3: double atof(), frand(); ! 4: long time(); ! 5: int eflag; ! 6: char line[BUFSIZ]; ! 7: main(argc,argv) char **argv; ! 8: { ! 9: int i,c; ! 10: for(i=1;i<argc;i++) ! 11: { if(*argv[i]!='-') ! 12: fract=atof(argv[i]); ! 13: else if((c=argv[i][1])=='e') ! 14: eflag=1; ! 15: } ! 16: srand((int)time(0)); ! 17: if(eflag==0) ! 18: while(gets(line,sizeof(line))) { ! 19: if(frand()*fract<1) ! 20: puts(line); ! 21: } ! 22: else ! 23: return(nrand((int)fract)); ! 24: return(0); ! 25: } ! 26: ! 27: gets(s,n) ! 28: char *s; ! 29: { ! 30: int c; ! 31: for(;;) { ! 32: c = getchar(); ! 33: if(c==EOF) ! 34: return 0; ! 35: if(c=='\n') ! 36: break; ! 37: *s++ = c; ! 38: } ! 39: *s = 0; ! 40: return 1; ! 41: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.