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

ÎÒµÄCʵ¼ù(9)£ºÎ»ºÍ×Ö½ÚµÄÖØÅÅ

  λºÍ×Ö½ÚµÄÖØÅÅÔÚÃÜÂëѧËã·¨ÖÐÓй㷺µÄÓ¦Óá£
/* rearran.c£ºÎ»ºÍ×Ö½ÚµÄÖØÅÅ */
/* λ·´×ª£ºÒÔ×ÖµÄÖÐÐÄΪ¶Ô³Æµã½øÐÐλ·´Éä
ÀýÈ磺 abcd efgh ijkl mnop ABCD EFGH IJKL MNOP
λ·´×ª£ºPONM LKJI HGFE DCBA ponm lkji hgfe dcba */
unsigned rev(unsigned x){
/* ½»»»ÏàÁڵĵ¥¸öλ */
x=(x & 0x55555555)<<1 | (x & 0xaaaaaaaa)>>1;
/* ½»»»ÏàÁÚµÄ2λ×ֶΠ*/
x=(x & 0x33333333)<<2 | (x & 0xcccccccc)>>2;
/* ½»»»ÏàÁÚµÄ4λ×ֶΠ*/
x=(x & 0x0f0f0f0f)<<4 | (x & 0xf0f0f0f0)>>4;
/* ½»»»ÏàÁÚµÄ8λ×ֶΠ*/
x=(x & 0x00ff00ff)<<8 | (x & 0xff00ff00)>>8;
/* ½»»»ÏàÁÚµÄ16λ×ֶΠ*/
x=(x & 0x0000ffff)<<16 | (x & 0xffff0000)>>16;
return x;
}
/* ×Ö½Ú·´×ª£ºÒÔ×ÖµÄÖÐÐÄΪ¶Ô³Æµã½øÐÐ×Ö½Ú·´Éä
ÀýÈ磺 abcd efgh ijkl mnop ABCD EFGH IJKL MNOP
×Ö½Ú·´×ª£ºIJKL MNOP ABCD EFGH ijkl mnop abcd efgh */
unsigned revw(unsigned x){
x=(x & 0x00ff00ff)<<8 | (x & 0xff00ff00)>>8;
x=(x & 0x0000ffff)<<16 | (x & 0xffff0000)>>16;
return x;
}
/* λ»ìÏ´£º½«ÓÒ°ë×ֵĸ÷¸öλÏà¼äµØ²åÈëµ½×ó°ë×ÖÖУ¬Î²²¿µÄλÈÔÈ»±£ÁôÔÚβ²¿
ÀýÈ磺abcd efgh ijkl mnop ABCD EFGH IJKL MNOP
»ìÏ´£ºaAbB cCdD eEfF gGhH iIjJ kKlL mMnN oOpP */
unsigned shuffling(unsigned x){
unsigned t;
/* ³õʼ£ºabcd efgh ijkl mnop ABCD EFGH IJKL MNOP */
/* abcd efgh ABCD EFGH ijkl mnop IJKL MNOP */
t=(x ^ (x>>8)) & 0x0000ff00; x=x ^ t ^ (t<<8);
/* abcd ABCD efgh EFGH ijkl IJKL mnop MNOP */
t=(x ^ (x>>4)) & 0x00f000f0; x=x ^ t ^ (t<<4);
/* abAB cdCD efEf ghGH ijIJ klKL mnMN opOP */
t=(x ^ (x>>2)) & 0x0c0c0c0c; x=x ^ t ^ (t<<2);
/* aAbB cCdD eEfF gGhH iIjJ kKlL mMnN oOpP */
t=(x ^ (x>>1)) & 0x22222222; x=x ^ t ^ (t<<1);
return x;
}
/* Äæ»ìÏ´ */
unsigned unshuffling(unsigned x){
/* ÒÔÏà·´µÄ˳Ðò½øÐн»»»¼´¿ÉʵÏÖÄæ»ìÏ´ */
t=(x ^ (x>>1)) & 0x22222222; x=x ^ t ^ (t<&


Ïà¹ØÎĵµ£º

ͨ¹ý#pragma pack(n)¸Ä±äC±àÒëÆ÷µÄ×Ö½Ú¶ÔÆ뷽ʽ

ÔÚCÓïÑÔÖУ¬½á¹¹ÊÇÒ»ÖÖ¸´ºÏÊý¾ÝÀàÐÍ£¬Æä¹¹³ÉÔªËؼȿÉÒÔÊÇ»ù±¾Êý¾ÝÀàÐÍ£¨Èçint¡¢long¡¢floatµÈ£©µÄ±äÁ¿£¬Ò²¿É
ÒÔÊÇһЩ¸´ºÏÊý¾ÝÀàÐÍ£¨ÈçÊý×é¡¢½á¹¹¡¢ÁªºÏµÈ£©µÄÊý¾Ýµ¥Ôª¡£ÔڽṹÖУ¬±àÒëÆ÷Ϊ½á¹¹µÄÿ¸ö³ÉÔ±°´Æä×ÔÈ»¶Ô½ç£¨alignment£©Ìõ¼þ·ÖÅä¿Õ¼ä¡£¸÷¸ö³ÉÔ±
°´ÕÕËüÃDZ»ÉùÃ÷µÄ˳ÐòÔÚÄÚ´æÖÐ˳Ðò´æ´¢£¬µÚÒ»¸ö³ÉÔ±µÄµØÖ·ºÍÕû¸ö ......

no acceptable C compiler found in $PATH

GCC°²×°³É¹¦,ËùÐèÎļþÓÐ:
libf2c-3.3.2-1.i386.rpm
libstdc++-devel-3.3.2-1.i386.rpm
glibc-kernheaders-2.4-8.36.i386.rpm
glibc-headers-2.3.2-101.i386.rpm
glibc-devel-2.3.2-101.i386.rpm
gcc-objc-3.3.2-1.i386.rpm
binutils-2.14.90.0.6-3.i386.rpm
gcc-3.3.2-1.i386.rpm
gcc-c++-3.3.2-1.i386.rpm
autom ......

C ±ê×¼¿â º¯Êý Ô´´úÂëµÄʵÏÖ ºÍ ·ÖÎö

//¿âº¯ÊýʵÏÖ
char *strcat (char *dst, const char *src)
{
  char *p = dst;
  while (*p)
    p++;
  while ((*p++ = *src++))
    ;
  return dst;
}
char *strncat (char *s1, const char *s2, long unsigned int n)
{
  char *dest = s1;
  ......

¡ïÔõÑùѧϰCÓïÑÔ(Ï׸øÃÔãµÄC°®ºÃÕß)¡ï

Ò» £¬ÔõÑùѧϰCÓïÑÔ
     ºÜ¶àÈ˶ÔѧϰCÓïÑԸе½ÎÞ´ÓÏÂÊÖ£¬¾­³£ÎÊÎÒͬһ¸öÎÊÌ⣺¾¿¾¹ÔõÑùѧϰCÓïÑÔ£¿ÎÒÊÇÒ»¸ö½Ìʦ£¬ÒѾ­¿ª·¢Á˺ܶàÄêµÄ³ÌÐò£¬ºÍºÜ¶à¸Õ¸ÕÆð²½µÄÈËÒ»Ñù£¬Ñ§Ï°µÄµÚÒ»¸ö¼ÆËã»úÓïÑÔ¾ÍÊÇCÓïÑÔ¡£¾­¹ýÕâЩÄêµÄ¿ª·¢£¬ÎÒÉîÉîµÄÌå»áµ½CÓïÑÔ¶ÔÓÚÒ»¸ö³ÌÐòÉè¼ÆÈËÔ±¶àôµÄÖØÒª£¬Èç¹û²»¶®CÓ ......

ÓÖÊÇ3Ö»C¡£¡£¡£= =

1.д³öÁ½¸öº¯Êý£¬·Ö±ðÇóÁ½¸öÕûÊýµÄ×î´ó¹«Ô¼ÊýºÍ×îС¹«±¶Êý£¬ÓÃÖ÷º¯Êýµ÷ÓÃÕâÁ½¸öº¯Êý£¬²¢Êä³ö½á¹û¡£Á½¸öÕûÊýÓɼüÅÌÊäÈë¡£
#include<stdio.h>
int gcd(int,int);
int lcm(int,int);
int gcd(int m,int n)
{
if(m%n==0)
return n;
else
return gcd(n,m%n);
}
int lcm(int m,int n)
{
return m*n/(gc ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ