更新时间:2018-11-22 15:53作者:王华老师
getchar();
scanf("%c",&num);
bit_set(&a,num,0);
printf("%d\n",a);
return1;
}
3.请用C语言实现字符串右循环移位函数,比如〞abcdefghi〞循环右移2位就是〞hiabcdefg〞。
函数原型: void RightLoopMove(char * pStr,unsignedshort steps)
参数说明:
pStr:Pointer to aˊ\0ˊterminated string
steps:The rotate shift numbers
#include
#include
#include
voidRightLoopMove(char* pStr,unsigned short steps)
{
unsigned short i=strlen(pStr);
int num=0;
char temp[10];
for(;num
{
static int length=i-steps;
temp[num]=pStr[length];
length++ ;
}
for(num=i-1-steps;num>=0;num--)
{
pStr[num+steps]=pStr[num];
}
for(num=0;num
{
pStr[num]=temp[num];
}
}
intmain(int argc,char* argv[])
{
char str[20]="abcdefghi";