Example #1
0
int main()
{
    char string[200],word[20][10],*p,*t,*l;
    int count[50]={0},m,i,j=0,cout=0,flag=0,len;
    gets(string);p=string;/*len=strlen(string);
    string[len]=' ';string[len+1]='\n';*/
    printf("Enter the mth number : ");
    scanf("%d",&m);l=p;p++;
    
    for(i=0;*l!='\n';)
    {p--;
    if(*p=='\n')
    break;
    p++;
    t=p;
            while(*p!=' ')
            {p++;
            }j=0;
            while(j<cout)
              {                        
                        if(!(strcmp_(&word[j][0],t,p-t)))
                        {++count[j];
                        flag=1;
                             break;
                        }
                             j++;
              }    
             if(!flag)
              { strcpy_(&word[cout][0],t,p-t);
               cout++;
              }
              l=p;
              p++;                  
      }
      
     for(i=0;i<cout;i++)
      {
                     // if(count[i]==m)
                         {printf("\nThe %d th most frequent word is %s",m,&word[i][0]);
                          }
}
}
Example #2
0
double oneChannel(double Xf,double Beps,char*n1,char*n2,char*n3,char*n4)
{ int j,nPrc;
  aChannel *wPrc;
  double Sum,res;
  
  MassCut=Mcdm*(2-log(Beps)/Xf);
  Sum=aRate(Xf, 1,1,&wPrc,&nPrc)*(Mcdm/Xf)*sqrt(M_PI/45)*MPlank/(2.742E8*Mcdm);
  
  if(FError)     { return -1;}
  if(wPrc==NULL) { return  0;}  

  for(res=0,j=0;j<nPrc;j++) 
  if( ( (strcmp_(n1,wPrc[j].prtcl[0])==0 && strcmp_(n2,wPrc[j].prtcl[1])==0) ||
        (strcmp_(n2,wPrc[j].prtcl[0])==0 && strcmp_(n1,wPrc[j].prtcl[1])==0)
      ) &&
      ( (strcmp_(n3,wPrc[j].prtcl[2])==0 && strcmp_(n4,wPrc[j].prtcl[3])==0) ||
        (strcmp_(n4,wPrc[j].prtcl[2])==0 && strcmp_(n3,wPrc[j].prtcl[3])==0)
      )
    )  {res+=wPrc[j].weight;} 
      
  free(wPrc); 
  return res;
}
Example #3
0
//快速排序算法 现在我貌似的确是写不出来啊 2016-2-2 bill
void  qsort_( char *lineptr[],int left,  int right )
{
	int i, last;
	
	void swap( char *v[], int ,int );
	
	if ( left >= right)
		return ;
	
	swap( lineptr, left, (left + right)/2 );
	
	last = left;
	
	for ( i= left + 1; i <= right; i++ ){
		if ( strcmp_( lineptr[i], lineptr[left]) < 0)
				swap( lineptr, ++last, i );	
	}
	
	swap( lineptr, left, last);
	qsort_( lineptr , left, last - 1 );	
	qsort_ ( lineptr, last + 1, right);	
}