C×Ö·û´®·´×ªËã·¨
Ò»¸öºÜ¼ò½àµÄËã·¨£º
void Reverse(char s[])
{
for(int i = 0, j = strlen(s) - 1; i < j; ++i, --j) {
char c = s[i];
s[i] = s[j];
s[j] = c;
}
}
#¹ØÓÚa, b½»»»ÆäËüËã·¨£º
a ^= b;
b ^= a;
a ^= b;
Ò»¸öÎåÖֽⷨµÄ°æ±¾£º
ת×Ô£ºhttp://www.cnblogs.com/Mainz/articles/1164602.html
ÕâÊÇÍøÂçÁ÷´«µÄMicrosoftµÄÃæÊÔÌâÄ¿Ö®Ò»£º“±àд·´×ª×Ö·û´®µÄ³ÌÐò£¬ÒªÇóÓÅ»¯Ëٶȡ¢ÓÅ»¯¿Õ¼ä”¡£ÒòΪ×î½üÒ»Ö±ºÜ¶à¹Ø×¢Ëã·¨·½ÃæµÄʵ¼ùºÍÑо¿£¬Òò´Ë¶ÔÕâ¸öÎÊÌâ½øÐÐÁËһЩ˼¿¼£¬¸ø³öÁË5ÖÖʵÏÖ·½·¨£¨ÓÐÁ½ÖֽⷨÏà¹ØÐԱȽϴ󣩡£
½â·¨Ò»£ºµÚÒ»´Î¿´µ½ÕâÌâÄ¿£¬Ïëµ½×î¼òµ¥¡¢×îÖ±¾õµÄ½â·¨¾ÍÊÇ£º±éÀú×Ö·û´®£¬½«µÚÒ»¸ö×Ö·ûºÍ×îºóÒ»¸ö½»»»£¬µÚ¶þ¸öºÍµ¹ÊýµÚ¶þ¸ö½»»»£¬ÒÀ´ÎÑ»·£¬¼´¿É£¬ÓÚÊÇÓÐÁ˵ÚÒ»¸ö½â·¨£º
char* strrev1(const char* str)
{
int len = strlen(str);
char* tmp = new char[len + 1];
strcpy(tmp,str);
for (int i = 0; i < len/2; ++i)
{
char c = tmp[i];
tmp[i] = tmp[len – i - 1];
tmp[len – i - 1] = c;
}
return tmp;
}
ÕâÀïÊÇͨ¹ýÊý×éµÄϱ귽ʽ·ÃÎÊ×Ö·û´®µÄ×Ö·û£¬Êµ¼ÊÉÏÓÃÖ¸ÕëÖ±½Ó²Ù×÷¼´¿É¡£½â·¨¶þÕýÊÇ»ùÓÚ´Ë£¬ÊµÏÖ´úÂëΪ£º
char* strrev2(const char* str)
{
char* tmp = new char[strlen(str) + 1];
strcpy(tmp,str);
char* ret = tmp;
char* p =
Ïà¹ØÎĵµ£º
±¾ÎĹؼü´Ê£º c++ º¬Òå
1.ÒýÑÔ
C++ÓïÑԵĴ´½¨³õÖÔÊÇ“a better C”£¬µ«ÊÇÕâ²¢²»Òâζ×ÅC++ÖÐÀàËÆCÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëCÓïÑÔÍêÈ«Ïàͬ¡£×÷ΪһÖÖÓûÓëC¼æÈݵÄÓïÑÔ£¬C++±£ÁôÁËÒ»²¿·Ö¹ý³ÌʽÓïÑÔµÄÌص㣨±»ÊÀÈ˳ÆΪ“²»³¹µ×µØÃæÏò¶ÔÏ󔣩£¬Òò¶øËü¿ÉÒÔ¶¨Òå²»ÊôÓÚÈκÎÀàµÄÈ«¾Ö±äÁ¿ ......
·¢ÐÅÈË: RoachCock (·´¶¯Ñ§ÊõȨÍþ), ÐÅÇø: CPlusPlus
±ê Ìâ: extern "C" ÔĶÁ±Ê¼Ç
·¢ÐÅÕ¾: ˮľÉçÇø (Fri Mar 7 00:22:47 2008), Õ¾ÄÚ
±¾ÒÔΪºÜ¼òµ¥£¬×ÐϸÔĶÁÁËһϠC++ ±ê×¼£¬·¢ÏÖÄÚÈÝ»¹²»ÉÙ¡£×ܽáÁËһϡ£
Òªµã£º
º¯ÊýÀàÐÍ£¬º¯ÊýÃû£¬±äÁ¿Ãû¾ßÓÐÓïÑÔÁ´½ÓÐÔ£¬language linkage¡£
ÓïÑÔÁ´½ÓÐÔ¿ÉÄÜ»áÓ°Ïìµ½ ......
λºÍ×Ö½ÚµÄÖØÅÅÔÚÃÜÂëѧËã·¨ÖÐÓй㷺µÄÓ¦Óá£
/* rearran.c£ºÎ»ºÍ×Ö½ÚµÄÖØÅÅ */
/* λ·´×ª£ºÒÔ×ÖµÄÖÐÐÄΪ¶Ô³Æµã½øÐÐλ·´Éä
ÀýÈ磺 abcd efgh ijkl mnop ABCD EFGH IJKL MNOP
λ·´×ª£ºPONM LKJI HGFE DCBA ponm lkji hgfe dcba */
unsigned rev(unsigned x){
/* ½»»»ÏàÁڵĵ¥¸öλ */
x=(x & 0x5 ......
×¢ÒâÖ»Äܵ½2049Ä꣡
#define uchar unsigned char
#define uint unsigned int
#include <intrins.h>
/*
¹«ÀúÄê¶ÔÓ¦µÄÅ©ÀúÊý¾Ý,ÿÄêÈý×Ö½Ú,
¸ñʽµÚÒ»×Ö½ÚBIT7-4 λ±íʾÈòÔÂÔ·Ý,ֵΪ0 ΪÎÞÈòÔÂ,BIT3-0 ¶ÔӦũÀúµÚ1-4 ÔµĴóС
µÚ¶þ×Ö½ÚBIT7-0 ¶ÔӦũÀúµÚ5-12 Ô´óС,µÚÈý×Ö½ÚBIT7 ±íʾũÀúµÚ13 ¸öÔ´óÐ ......