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

C/C++ ±ÊÊÔ¡¢ÃæÊÔÌâÄ¿´ó»ã×Ü


1.ÇóÏÂÃ溯ÊýµÄ·µ»ØÖµ£¨ ΢Èí£©
int func(x)
{
    int countx = 0;
    while(x)
    {
          countx ++;
          x = x&(x-1);
     }
    return countx;

¼Ù¶¨x = 9999¡£ ´ð°¸£º8
˼·£º½«xת»¯Îª2½øÖÆ£¬¿´º¬ÓеÄ1µÄ¸öÊý¡£
2. ʲôÊÇ“ÒýÓÔ£¿ÉêÃ÷ºÍʹÓÓÒýÓÔҪעÒâÄÄЩÎÊÌ⣿
´ð£ºÒýÓþÍÊÇij¸öÄ¿±ê±äÁ¿µÄ“±ðÃû”(alias)£¬¶ÔÓ¦ÓõIJÙ×÷Óë¶Ô±äÁ¿Ö±½Ó²Ù×÷Ч¹ûÍêÈ«Ïàͬ¡£ÉêÃ÷Ò»¸öÒýÓõÄʱºò£¬ÇмÇÒª¶ÔÆä½øÐгõʼ»¯¡£ÒýÓÃÉùÃ÷Íê±Ïºó£¬Ï൱ÓÚÄ¿±ê±äÁ¿ÃûÓÐÁ½¸öÃû³Æ£¬¼´¸ÃÄ¿±êÔ­Ãû³ÆºÍÒýÓÃÃû£¬²»ÄÜÔٰѸÃÒýÓÃÃû×÷ΪÆäËû±äÁ¿ÃûµÄ±ðÃû¡£ÉùÃ÷Ò»¸öÒýÓ㬲»ÊÇж¨ÒåÁËÒ»¸ö±äÁ¿£¬ËüÖ»±íʾ¸ÃÒýÓÃÃûÊÇÄ¿±ê±äÁ¿ÃûµÄÒ»¸ö±ðÃû£¬Ëü±¾Éí²»ÊÇÒ»ÖÖÊý¾ÝÀàÐÍ£¬Òò´ËÒýÓñ¾Éí²»Õ¼´æ´¢µ¥Ôª£¬ÏµÍ³Ò²²»¸øÒýÓ÷ÖÅä´æ´¢µ¥Ôª¡£²»Äܽ¨Á¢Êý×éµÄÒýÓá£
3. ½«“ÒýÓÔ×÷Ϊº¯Êý²ÎÊýÓÐÄÄЩÌص㣿
£¨1£©´«µÝÒýÓøøº¯ÊýÓë´«µÝÖ¸ÕëµÄЧ¹ûÊÇÒ»ÑùµÄ¡£Õâʱ£¬±»µ÷º¯ÊýµÄÐβξͳÉΪԭÀ´Ö÷µ÷º¯ÊýÖеÄʵ²Î±äÁ¿»ò¶ÔÏóµÄÒ»¸ö±ðÃûÀ´Ê¹Óã¬ËùÒÔÔÚ±»µ÷º¯ÊýÖжÔÐβαäÁ¿µÄ²Ù×÷¾ÍÊǶÔÆäÏàÓ¦µÄÄ¿±ê¶ÔÏó£¨ÔÚÖ÷µ÷º¯ÊýÖУ©µÄ²Ù×÷¡£
£¨2£©Ê¹ÓÃÒýÓô«µÝº¯ÊýµÄ²ÎÊý£¬ÔÚÄÚ´æÖв¢Ã»ÓвúÉúʵ²ÎµÄ¸±±¾£¬ËüÊÇÖ±½Ó¶Ôʵ²Î²Ù×÷£»¶øʹÓÃÒ»°ã±äÁ¿´«µÝº¯ÊýµÄ²ÎÊý£¬µ±·¢Éúº¯Êýµ÷ÓÃʱ£¬ÐèÒª¸øÐβηÖÅä´æ´¢µ¥Ôª£¬ÐβαäÁ¿ÊÇʵ²Î±äÁ¿µÄ¸±±¾£»Èç¹û´«µÝµÄÊǶÔÏ󣬻¹½«µ÷Óÿ½±´¹¹Ô캯Êý¡£Òò´Ë£¬µ±²ÎÊý´«µÝµÄÊý¾Ý½Ï´óʱ£¬ÓÃÒýÓñÈÓÃÒ»°ã±äÁ¿´«µÝ²ÎÊýµÄЧÂʺÍËùÕ¼¿Õ¼ä¶¼ºÃ¡£
£¨3£©Ê¹ÓÃÖ¸Õë×÷Ϊº¯ÊýµÄ²ÎÊýËäȻҲÄÜ´ïµ½ÓëʹÓÃÒýÓõÄЧ¹û£¬µ«ÊÇ£¬ÔÚ±»µ÷º¯ÊýÖÐͬÑùÒª¸øÐβηÖÅä´æ´¢µ¥Ôª£¬ÇÒÐèÒªÖظ´Ê¹ÓÃ"*Ö¸Õë±äÁ¿Ãû"µÄÐÎʽ½øÐÐÔËË㣬ÕâºÜÈÝÒײúÉú´íÎóÇÒ³ÌÐòµÄÔĶÁÐԽϲÁíÒ»·½Ã棬ÔÚÖ÷µ÷º¯ÊýµÄµ÷Óõ㴦£¬±ØÐëÓñäÁ¿µÄµØÖ·×÷Ϊʵ²Î¡£¶øÒýÓøüÈÝÒ×ʹÓ㬸üÇåÎú¡£
4. ÔÚʲôʱºòÐèҪʹÓÓ³£ÒýÓÔ£¿¡¡
Èç¹û¼ÈÒªÀûÓÃÒýÓÃÌá¸ß³ÌÐòµÄЧÂÊ£¬ÓÖÒª±£»¤´«µÝ¸øº¯ÊýµÄÊý¾Ý²»ÔÚº¯ÊýÖб»¸Ä±ä£¬¾ÍӦʹÓó£ÒýÓᣳ£ÒýÓÃÉùÃ÷·½Ê½£ºconst ÀàÐͱêʶ·û &ÒýÓÃÃû=Ä¿±ê±äÁ¿Ãû£»
Àý1
int a ;
const int &ra=a;
ra=1; //´íÎó
a=1; //ÕýÈ·
Àý2
string


Ïà¹ØÎĵµ£º

C³ÌÐòÔ±µÄÇéÊé

#include <stdio.h>
#include <string.h>
int
main(void)
{
char str[] =
"3BVPSq4xF.K?=u#,"
"G'K<MrDnRr7gH%#,"
"XKf<f%G`w^=?C<#,"
"HgU_AnNR?*PDQU#,"
......

c³ÌÐòÉè¼ÆÓïÑÔÏ°Ìâ1 9

ÁªÏµ1-9±àдһ¸ö½«ÊäÈ븴ÖƵ½Êä³öµÄ³ÌÐò£¬²¢½«ÆäÖÐÁ¬ÐøµÄ¶à¸ö¿Õ¸ñÓÃÒ»¸ö¿Õ¸ñ´úÌæ¡£
#include "stdio.h"
main(){
int c;
int flag;
flag=0;//ÊÇ·ñ¿Õ¸ñ±êÖ¾
while ((c=getchar())!=EOF){
if (c!=32) {
putchar(c);
flag=0;
}else if(flag==0){
flag=1;
putchar(c);
}

/* ......

¼òÊöCºÍC++³ÌÐòԱѧϰÀú³Ì

¹þ¹þ£¡ÓÐÐÒÔÚijÍøÕ¾·¢ÏÖÕâƪÎÄÕ£¬¶Á°Õ£¬¾õµÃÂùÓеÀÀí£¬·¢À´´ó¼ÒÒ»Æð¹²ÃãÖ®    
×ÜÊDZ»Í¬Ñ§ÃÇÎʵ½£¬ÈçºÎѧϰCºÍC++²Å²»Ã£È»£¬²Å²»ÊÇÂÒѧ£¬ÏëÁËһϣ¬ÕâÀï¸ø³öÒ»¸ö×ܵĻظ´¡£ 
' J$ |0 ?! p% w" t5 D6 D: c9 |0 B
¡¡¡¡Ò»¼ÒÖ®ÑÔ£¬»¶Ó­ÅÄש¹þ¡£ 
¡¡¡¡1¡¢¿ÉÒÔ¿¼ÂÇÏÈѧϰC. 
/ U$ X+ X/ P; Y ......

CÖ¸ÕëÒÜÏë

Ö¸Õë,ÖÚËùÖÜÖª,ʱΪһÄÚ´æµØÖ·.Å׿ªOS¼¶±ð»ò¸üµÍµÄÓ²¼þ¼¶±ð²»Ëµ,½ö¶ÔÓ¦ÓÃÄÚµÄʹÓýøÐÐССµÄÒܲâÌÖÂÛ.
Ê×ÏÈ,ÔÚÓ¦ÓÃÄÚ,ÓÃmallocÉêÇëµ½µÄÒ»¿éµØÖ·Ó¦¸ÃÊÇÁ¬ÐøµÄ(²Â²â,Âß¼­ÉÏÁ¬Ðø,ʵ¼ÊÉÏÎïÀíÈçºÎ·Ö²¼²»Óè¹Ø×¢).
Æä´Î,Êý¾Ý´æÔÚÔÚÄÚ´æÖж¼ÊÇÒÔ2½øÖÆÐÎʽ´æ·Å.²»´æÔÚÊý¾ÝÀàÐÍ,Òò´Ë,¶ÔÄÚ´æÊý¾ÝµÄ²Ù×÷,Ö»Òª×ñÑ­½ø³öÀàÐÍÒ»Ö¼´¿É.
´ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ