http://blog.youkuaiyun.com/hackbuteer1/article/details/8035261
// 把数组中基数位的数移到数组后半部_并保持相对位置不变.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "string.h"
//a1b2c3d4e5->abcde12345
void swap(char *Array, int idx1, int idx2)
{
char tmp = Array[idx1];
Array[idx1] = Array[idx2];
Array[idx2] = tmp;
}
void swapArray(char *Array, int startIdx, int len)
{
int targetIdx = startIdx+len;
int loop = startIdx;
while (targetIdx > startIdx)
{
swap(Array, targetIdx-1, targetIdx);
targetIdx--;
}
}
、、http://blog.youkuaiyun.com/hackbuteer1/article/details/8035261
void modifyArray(char *Array, int len)
{
int switchTimes = len/2 - 1;
for (int tryIdx = 1; tryIdx <= switchTimes; tryIdx++)
{
swapArray(Array, tryIdx, tryIdx);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
char A[] = "a1b2c3d4e5f6";
modifyArray(A, 12);
return 0;
}
http://blog.youkuaiyun.com/hackbuteer1/article/details/8035261