Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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++ÖÐextern ¡°C¡±º¬ÒåÉî²ã̽Ë÷

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

c/c++ʵÏÖÒ»¸öÃܼ¯ÐÍserver/socket¶à·¸´ÓÃselect


×÷Ò»¸ötcpµÄ·þÎñ³ÌÐò£¬Í¬Ê±¿ÉÄÜÓдóÁ¿µÄ¿Í»§¶ËÁ¬ÉÏÀ´£¬Ï£Íû·Ö±ð¼Çס¸÷¸ösocket
Ë­ÓÐÊý¾Ý¹ýÀ´£¬¾Í¶Á³öÀ´£¬·Åµ½Ò»¸öÇëÇó¶ÓÁУ­£­ÕâЩÊÂÇéÓÃÒ»¸öÏß³ÌÍê³É
 
ÁíÍâÓÐÒ»¸ö½á¹û¶ÓÁУ¬Èç¹û½á¹ûÀï°üº¬ÁËsocketµÄ±àºÅ£¬ÓÃÒ»¸öÏß³ÌרÃÅ£º
È¡³öÀ´°´±àºÅÕÒ»ØÔ­À´·¢ËÍÕßsocket£¬·¢»Ø¸øÔ­À´µÄ¿Í»§¶Ë
 
»¹ÓÐÒ»¸ö¾ÍÊÇ´¦ÀíÏ ......

C51: MIXING C AND ASSEMBLY

ÒÔÏÂÈ«ÎÄתÔØ×Ôhttp://www.keil.com/support/docs/1671.htm                     Copyright © 2010 Keil™, An ARM® Company.
Information in this article applies to:
C51 Version 6.02
&mi ......

C/C++ÓïÑÔ±à³ÌÐÞÑø1£¨×ª£©

ʲôÊǺõijÌÐòÔ±£¿ÊDz»ÊǶ®µÃºÜ¶à¼¼Êõϸ½Ú£¿»¹ÊǶ®µ×²ã±à³Ì£¿»¹ÊDZà³ÌËٶȱȽϿ죿
ÎÒ¾õµÃ¶¼²»ÊÇ¡£¶ÔÓÚһЩ¼¼Êõϸ½ÚÀ´ËµºÍµ×²ãµÄ¼¼Êõ£¬Ö»Òª¿´°ïÖú£¬²é×ÊÁϾÍÄÜÕÒµ½£¬¶Ô
ÓÚËٶȿ죬ֻҪ±àµÃ¶àÒ²¾ÍÊìÄÜÉúÇÉÁË¡£
 
ÎÒÈÏΪºÃµÄ³ÌÐòÔ±Ó¦¸ÃÓÐÒÔϼ¸·½ÃæµÄËØÖÊ£º
 
  1¡¢ÓÐרÑо«Éñ£¬ÇÚѧÉÆÎÊ¡¢¾ÙÒ»·´ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ