Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

c³ÌÐòʵÏÖÏãÅ©±àÂë

#include <stdio.h>
#include <math.h>
#include <string.h>
int i,j,n,k,b;
float addp;
char bitw[20];
/*³õʼ»¯½á¹¹ÌåÆäÖУºsΪÐÅÔ´·ûºÅ£»pΪÐÅÔ´·ûºÅ¸ÅÂÊ£»paddΪÀÛ¼Ó¸ÅÂÊ£»
l_fΪ-log[p(s[i])]¼´¹À¼ÆÂë×Ö³¤¶È£»lΪʵ¼ÊÐèÒªÂë×Ö³¤¶È£»wΪÂë×Ö*/
 struct shan
 {char s[20];
  float p;
  float padd;
  float l_f;
  int l;
  char w[20];
 }data[12];
/*ÒÀÐÅÔ´¸ÅÂʶԸ÷ÐÅÔ´·ûºÅÅÅÐòMoai&KevinÔ­´´£¡*/
void sequ(struct shan x[],int n)
{
 struct shan temp;
 for(i=0;i<n;i++)
  for(j=i;j<n;j++)
  {if(x[i].p<x[j].p)
   {
  temp=x[j];
  x[j]=x[i];
  x[i]=temp;
   }
  }
}
/*¼ÆËãÀÛ¼Ó¸ÅÂÊ*/
void countpadd(struct shan x[],int n)
{
  addp=0;
  x[0].padd=0;
  for(i=0;i<n;i++)
  {
 addp+=x[i].p;
 x[i+1].padd=addp;
  }
}
/*¼ÆËã¹À¼ÆÂë×Ö³¤¶Èl_f£¬ÒÔ¼°Moai&KevinÔ­´´£¡*/Âë×Ö³¤¶Èl*/
void count_l(struct shan x[],int n)
{
  for(i=0;i<n;i++)
  {
 x[i].l_f=-log(x[i].p)/log(2);
    if((x[i].l_f-(int)x[i].l_f)>0)
  x[i].l=(int)x[i].l_f+1;
 else x[i].l=(int)x[i].l_f;
  }
}
/*¶þ½øÖÆ×ª»»*/
void covbit(float a,int lc)
{
  for(j=0;j<lc;j++)
  { 
   b=(int)(a*2);
   bitw[j]=b+48;
   a=2*a-int(a*2);
  }
 }
main()
{
 printf("please input the number of symbols of source(n<=10):n=");
 scanf("%d",&n);
 printf("please input the the source symbols and their probabilities\n");
 /*»ñÈ¡ÐÅÔ´·ûºÅ*/
 for(i=0;i<n;i++)
 {
 scanf("%s",data[i].s);
 }
 /*»ñÈ¡ÐÅÔ´Moai&KevinÔ­´´£¡*/¸ÅÂÊ*/
 for(i=0;i<n;i++)
 {printf("P(%s)=",data[i].s);
  scanf("%f",&data[i].p);
 }
 sequ(data,n);
 countpadd(data,n);
 count_l(data,n);
 /*ÔڽṹÌåÖвúÉúÂë×Ö*/
 for(i=0;i<n;i++)
 {


Ïà¹ØÎĵµ£º

¹ØÓÚCµÄ˼¿¼


¹ØÓÚCµÄ˼¿¼
Cong Wang
May, 2006
Network Engineering Department
Institute of Post and Telecommunications, Xi'an, P.R.China
ÒýÑÔ
    CÓïÑÔ½áºÏÁË»ã±àµÄËùÓÐÍþÁ¦£¬ËüµÄ³éÏó³Ì¶ÈÅöÇɼÈÂú×ãÁ˳ÌÐòÔ±µÄÒªÇó, ÓÖÈÝÒ×ʵÏÖ¡£ÒòÆä¶ÀÌØµÄÁé»îÐÔºÍÇ¿´óµÄ¿ÉÒÆÖ²ÐÔ£¬ÏµÍ³³ÌÐòÔ±ºÍºÚ¿ÍÃǸüÊǶÔËüÖÓ°® ......

Pro*C SQLDA ½á¹¹Ìå

--Õª×Ô ¡¶Oracle Pro*C ³ÌÐò¿ª·¢¡·     --Create/Modify Email£ºxingchengli@gmail.com
SQLDA µÄ½á¹¹ÈçÏ£º
struct SQLDA
{
long N; /* Descriptor size in number of entries */
char **V; Ptr to Arr of addresses of main variables */
long *L; /* Ptr to Arr of lengths of buffe ......

C++ÖÐextern ¡°C¡±º¬ÒåÉî²ã̽Ë÷

1.ÒýÑÔ
¡¡¡¡C++ÓïÑԵĴ´½¨³õÖÔÊÇ“a better C”£¬µ«ÊÇÕâ²¢²»Òâζ×ÅC++ÖÐÀàËÆCÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëCÓïÑÔÍêÈ«Ïàͬ¡£×÷ΪһÖÖÓûÓëC¼æÈݵÄÓïÑÔ£¬C++±£ÁôÁËÒ»²¿·Ö¹ý³ÌʽÓïÑÔµÄÌØµã£¨±»ÊÀÈ˳ÆÎª“²»³¹µ×µØÃæÏò¶ÔÏ󔣩£¬Òò¶øËü¿ÉÒÔ¶¨Òå²»ÊôÓÚÈκÎÀàµÄÈ«¾Ö±äÁ¿ºÍº¯Êý¡£µ«ÊÇ£¬C++±Ï¾ ......

C/C++ÓïÑÔ±à³ÌÐÞÑø2

21¡¢gotoÓï¾äµÄʹÓÃ
—————————
 
NÄêǰ£¬Èí¼þ¿ª·¢µÄÒ»´ú×Úʦ——µÏ½ÜË¹ÌØÀ­(Dijkstra)˵¹ý£º“goto statment is
harmful !!”£¬²¢½¨ÒéÈ¡ÏûgotoÓï¾ä¡£ÒòΪgotoÓï¾ä²»ÀûÓÚ³ÌÐò´úÂëµÄά»¤ÐÔ¡£
 
ÕâÀïÎÒҲǿÁÒ½¨Ò鲻ҪʹÓÃgo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ