当前位置:网站首页>练习8-8 移动字母 (10 分)
练习8-8 移动字母 (10 分)
2022-06-11 22:19:00 【小言同学Y】
本题要求编写函数,将输入字符串的前3个字符移到最后。
函数接口定义:
void Shift( char s[] );
其中char s[]是用户传入的字符串,题目保证其长度不小于3;函数Shift须将按照要求变换后的字符串仍然存在s[]里。
裁判测试程序样例:
#include <stdio.h>
#include <string.h>#define MAXS 10
void Shift( char s[] );
void GetString( char s[] ); /* 实现细节在此不表 */
int main()
{
char s[MAXS];GetString(s);
Shift(s);
printf("%s\n", s);return 0;
}/* 你的代码将被嵌在这里 */
输入样例:
abcdef
输出样例:
defabc
void Shift( char s[] ){
char ch[3];
int i,j,count=0;
for(i=0;i<3;i++){ //存放前三个字符
ch[i]=s[i];
}
for(i=0;i<strlen(s)-3;i++){ //将后面的字符往前移
count++;
s[i]=s[i+3];
}
for(i=count,j=0;i<MAXS;i++,j++){ //将前三个字符移到最后
s[i]=ch[j];
}
}
边栏推荐
- Introduction to MySQL transactions
- Basic operation and question type summary of binary tree
- SequenceList顺序表的实现
- 什么是死锁?(把死锁给大家讲明白,知道是什么,为什么用,怎么用)
- If I take the college entrance examination again, I will study mathematics well!
- 67. binary sum
- Lecture de l'article dense Visual SLAM for RGB - D Cameras
- NLP - fastText
- Unity3d getlaunchintintforpackage getting package returned null
- 详解异步任务:函数计算的任务触发去重
猜你喜欢

移动端——swipe特效之图片时间轴

What is deadlock? (explain the deadlock to everyone and know what it is, why it is used and how to use it)

Huawei equipment configuration hovpn

360 online enterprise security cloud is open to small, medium and micro enterprises for free

Tkinter学习笔记(四)

Study notes of mattlotlib and Tkinter (I)

win10字体模糊怎么调节

图的基本操作(C语言)
![[niuke.com] dp31 [template] complete Backpack](/img/81/5f35a58c48f05a5b4b6bdc106f5da0.jpg)
[niuke.com] dp31 [template] complete Backpack

Maze problem in C language
随机推荐
Analysis of the implementation principle of an open source markdown to rich text editor
Implementation of sequencelist sequence table
Use the securecrtportable script function to read data from network devices
Matlab: solution of folder locking problem
Basic operation and question type summary of binary tree
5.学城项目 支付宝支付
Superscalar processor design yaoyongbin Chapter 2 cache -- Excerpt from subsection 2.4
Implementation stack and queue
[Yu Yue education] calculus of Zhejiang University in autumn and winter 2021 (I) reference materials
The college entrance examination is over, and life has just begun. Suggestions from a 10-year veteran in the workplace
点云读写(二):读写txt点云(空格分隔 | 逗号分隔)
Unity3D getLaunchIntentForPackage 获取包返回null问题
[JS] 1347- high level usage of localstorage
SequenceList顺序表的实现
STM32 Development Notes 112:ads1258 driver design - read register
The device is in use when win10 ejects USB
3.3 测试模块的命名规则
R language book learning 03 "in simple terms R language data analysis" - Chapter 7 linear regression model
One question of the day - delete duplicates of the ordered array
Static PVC with CEPH CSI