-->
当前位置:首页 > 题库 > 正文内容

函数题:字符数组-字符循环右移

Luz3年前 (2022-04-13)题库942
定义函数,将字符串循环右移n个字符,例如abcde循环右移两位:deabc

### 函数接口定义:
c++
void fun(char *str,int n)

### 裁判测试程序样例:
c++
在这里给出函数被调用进行测试的例子。例如:
#include <stdio.h>

void fun(char *str,int n);

int main()
{

char s[20];
int n;
scanf("%s%d", s,&n);
fun(s,n);
printf("%s", s);

return 0;

}

/* 请在这里填写答案 */


### 输入样例:

在这里给出一组输入。例如:

in
abcdef 2


### 输出样例:

在这里给出相应的输出。例如:

out
efabcd







答案:若无答案欢迎评论

评论列表

zmxncbv
zmxncbv
3年前 (2022-05-01)

#include
#include
void fun(char *str,int n){
int len=strlen(str)-n;
char temp[1024];
strcpy(temp,str+len);
strcpy(temp+n,str);
*(temp+n+len)='\0';
strcpy(str,temp);
}

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。