#include #include #include int compf(const void *a,const void *b) { if (*(unsigned short *)a > *(unsigned short *)b) return 1; else if (*(unsigned short *)a < *(unsigned short *)b) return -1; else return 0; } int main(int argc,char **argv) { static unsigned short dat[1200*1800]; static unsigned short p[1200]; static unsigned short q[1800]; double f; double ff; double q1; double q2; int i; int j; fread(dat,sizeof(unsigned short),1200*1800,stdin); for (i=0;i<1800;i++) { for (j=0;j<1200;j++) p[j]=dat[j*1800+i]; qsort(p,1200,sizeof(unsigned short),compf); q[i]=p[600]; } for (i=0;i<900;i++) { f=13.56+(40.56-13.56)/900.0*i; // 452=>13.56 1352=>40.56 ff=20*log10(f); q1=q[i ]/100.0+ff-270; q2=q[i+900]/100.0+ff-270; printf("%s %6.3lf %6.1lf %6.1lf\n",argv[1],f,q1,q2); } printf("\n"); exit(0); }