#include #include #define BSIZE 200 #define CLASSES 4 char buff[BSIZE+1]; int prop[CLASSES]; main(argc,argv) int argc; char **argv; { while ( fgets(buff,BSIZE,stdin) ) { char *bp; int i; int sum = 0; for ( i=0; i<4; i++ ) prop[i] = 0; for ( bp=buff; *bp && *bp!='\n'; bp++ ) { sum++; if ( isspace(*bp) ) prop[0]++; else if ( isdigit(*bp) ) prop[1]++; else if ( isalpha(*bp) ) prop[2]++; else prop[3]++; } if ( sum == 0 ) continue; for ( i=0; i<4; i++ ) { double p = ((double)prop[i]) / ((double)sum); printf("%8.3f ",p); } printf(" %s\n",argv[1]); } }