当前位置:网站首页>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];
}
}
边栏推荐
- STM32开发笔记112:ADS1258驱动设计——读寄存器
- 【LeetCode】11. Container with the most water
- If I take the college entrance examination again, I will study mathematics well!
- leetcode 257. Binary tree paths all paths to a binary tree (simple)
- R7-1 sum of numeric elements of a list or tuple
- What is deadlock? (explain the deadlock to everyone and know what it is, why it is used and how to use it)
- Implementation of stack stack
- Unity3D getLaunchIntentForPackage 获取包返回null问题
- 什么是死锁?(把死锁给大家讲明白,知道是什么,为什么用,怎么用)
- MATLAB点云处理(二十四):点云中值滤波(pcmedian)
猜你喜欢

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

Why is the printer unable to print the test page

二叉树的基本操作与题型总结

Players must read starfish NFT advanced introduction

NLP - fastText

A simple example of linear regression in machine learning

超标量处理器设计 姚永斌 第2章 Cache --2.4 小节摘录

Introduction to MySQL transactions

Precision twist jitter

Nmap performs analysis of all network segment IP survivals in host detection
随机推荐
图的基本操作(C语言)
3.2 测试类的命名规则
360 online enterprise security cloud is open to small, medium and micro enterprises for free
【Uniapp 原生插件】商米钱箱插件
Explain asynchronous tasks in detail: the task of function calculation triggers de duplication
Is the securities account recommended by qiniu safe? Is it reliable
[data mining time series analysis] restaurant sales forecast
crontab中定时执行shell脚本
打印机无法打印测试页是什么原因
Daily question -1317 Converts an integer to the sum of two zero free integers
二叉树的基本操作与题型总结
The device is in use when win10 ejects USB
Basic operation and question type summary of binary tree
238. product of arrays other than itself
R7-1 列表或元组的数字元素求和
还在直接用 localStorage 么?该提升下逼格了
Superscalar processor design yaoyongbin Chapter 2 cache -- Excerpt from subsection 2.3
习题8-8 判断回文字符串 (20 分)
SequenceList顺序表的实现
Brief introduction to integrity