PIPIONE
int shuru(int * yy,int len){printf("please input a number:\n");int n,i,j;scanf("%d",&n);for(i=0;i<n;i++){int temp=yy[len-1];for(j=len-1;j>0;j--){yy[j]=yy[j-1];}yy[0]=temp;}return 0; }int main(){int yy[]={1,2,3,4,5,6,7,8,9};n=sizeof yy/sizeof yy[0];shuru(yy,n);for(i=0;i<n;i++){printf("%d ",yy[i]);}printf("\n");}这里是一个整数型数组,不过操作是一样的。
DIEA
#include<iostream>using namespace std;void LoopMore(char *pstr,int steps){char *t=new char[steps];int len=strlen(pstr);memcpy(t,pstr+len-steps,sizeof(char)*steps);memcpy(pstr+steps,pstr,sizeof(char)*(len-steps));memcpy(pstr,t,sizeof(char)*steps);}int main(){char s[]="Hello,My name is xq.";LoopMore(s,3);cout << s;}