当前位置:网站首页>Exercise 8-8 moving letters (10 points)
Exercise 8-8 moving letters (10 points)
2022-06-11 22:25:00 【Xiaoyan y】
This problem requires writing functions , The first... Of the input string 3 Move characters to the last .
Function interface definition :
void Shift( char s[] );
among char s[] Is the string passed in by the user , Ensure that the length of the title is not less than 3; function Shift The string transformed as required must still exist s[] in .
Sample referee test procedure :
#include <stdio.h>
#include <string.h>#define MAXS 10
void Shift( char s[] );
void GetString( char s[] ); /* Implementation details are not shown here */
int main()
{
char s[MAXS];GetString(s);
Shift(s);
printf("%s\n", s);return 0;
}/* Your code will be embedded here */
sample input :
abcdef
sample output :
defabc
void Shift( char s[] ){
char ch[3];
int i,j,count=0;
for(i=0;i<3;i++){ // Store the first three characters
ch[i]=s[i];
}
for(i=0;i<strlen(s)-3;i++){ // Move the following characters forward
count++;
s[i]=s[i+3];
}
for(i=count,j=0;i<MAXS;i++,j++){ // Move the first three characters to the last
s[i]=ch[j];
}
}
边栏推荐
- 206. reverse linked list
- One question per day -- verifying palindrome string
- Zhanrui IOT chip 8910dm is certified by Deutsche Telekom
- [Yu Yue education] Yancheng Normal University Advanced Algebra reference
- MATLAB点云处理(二十五):点云生成 DEM(pc2dem)
- What is deadlock? (explain the deadlock to everyone and know what it is, why it is used and how to use it)
- Are you still using localstorage directly? It's time to raise the bar
- 机器学习之线性回归简单实例
- Use the securecrtportable script function to read data from network devices
- 利用SecureCRTPortable脚本功能完成网络设备的数据读取
猜你喜欢

Tkinter学习笔记(二)

一款开源的Markdown转富文本编辑器的实现原理剖析

Analysis of the implementation principle of an open source markdown to rich text editor

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

6.项目上线

Matplotlib和tkinter学习笔记(一)

仅需三步学会使用低代码ThingJS与森数据DIX数据对接

Superscalar processor design yaoyongbin Chapter 2 cache -- Excerpt from subsection 2.4

Players must read starfish NFT advanced introduction

超标量处理器设计 姚永斌 第2章 Cache --2.2 小节摘录
随机推荐
238. product of arrays other than itself
206. reverse linked list
One question per day -- verifying palindrome string
Basic operation of graph (C language)
NLP - fastText
Xshell不小心按到ctrl+s造成页面锁定的解决办法
[Yu Yue education] Yancheng Normal University Advanced Algebra reference
swiper——单页面多轮播插件冲突解决方案
MATLAB点云处理(二十四):点云中值滤波(pcmedian)
超标量处理器设计 姚永斌 第2章 Cache --2.2 小节摘录
[JS] 1347- high level usage of localstorage
Players must read starfish NFT advanced introduction
One question of the day - delete duplicates of the ordered array
5.学城项目 支付宝支付
【JS】1347- localStorage 的高阶用法
Non recursive writing of quick sort
分类统计字符个数 (15 分)
astra pro双目相机ros下启动笔记
MATLAB点云处理(二十五):点云生成 DEM(pc2dem)
什么是死锁?(把死锁给大家讲明白,知道是什么,为什么用,怎么用)