20140604

时间:2014-06-06 09:22:26   收藏:0   阅读:270

1、如在在word表格中打钩

符号->其他符号->字体(wingdings2)

bubuko.com,布布扣

2、循环右移

方法1:

bubuko.com,布布扣
#include<stdio.h>
void move(char *s)  //循环右移1位
{
    if(s==NULL)
        return;    
    char *p=s,*q=s;
    char temp;
    while(*p!=\0) 
    {
        p++;
    }
    p--;
    q=p-1;
    temp=*p;
    while(p!=s)
    {
        *p=*q;
        q--;
        p--;
    }
    *s=temp;
}
void LoopMove( char *pStr,int steps)//循环右移steps位
{
    int i=0;
    while(i<steps)
    {
        move(pStr);
        i++;
    }
}
void main()
{
    char str[]="abcdef";
    //char *str="abcdef";  这里“abcdef”是常量,不能通过str指针修改常量值,这种写法错误
    LoopMove(str,2);
    printf("%s",str);
}
bubuko.com,布布扣

方法2:

bubuko.com,布布扣
#include<stdio.h>
#include<string.h>
#include<malloc.h>
void LoopMove(char *pStr,int steps)
{
    int len=strlen(pStr);
    int n=len-steps;
    char *temp=(char *)malloc(sizeof(char *));
    strcpy(temp,pStr+n);
    strcpy(temp+steps,pStr);
    *(temp+len)=\0;
    strcpy(pStr,temp);
}

void main()
{
    char str[]="abcdef";
    LoopMove(str,2);
    printf("%s",str);
}
bubuko.com,布布扣

20140604,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!