当前位置:网站首页>练习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];
}
}
边栏推荐
- [niuke.com] DP30 [template] 01 Backpack
- [data mining time series analysis] restaurant sales forecast
- Non recursive writing of quick sort
- leetcode 257. Binary Tree Paths 二叉树的所有路径(简单)
- Tkinter study notes (IV)
- 使用VBScript读取网络的日志数据进行处理
- 超標量處理器設計 姚永斌 第2章 Cache --2.4 小節摘錄
- Dynamic memory management (1)
- Maze problem in C language
- R7-1 列表或元组的数字元素求和
猜你喜欢

BUUCTF(5)

Win10弹出USB时出现该设备正在使用的解决方法

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

leetcode 257. Binary Tree Paths 二叉树的所有路径(简单)

FastAPI 5 - 常用请求及 postman、curl 使用(parameters,x-www-form-urlencoded, raw)

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

Precision twist jitter
![[niuke.com] dp31 [template] complete Backpack](/img/81/5f35a58c48f05a5b4b6bdc106f5da0.jpg)
[niuke.com] dp31 [template] complete Backpack

【LeetCode】11. Container with the most water

Optimization of quick sort
随机推荐
Summary of common paging methods
启牛商学院送华泰账户安不安全?真的吗
win10字体模糊怎么调节
3.3 测试模块的命名规则
SequenceList顺序表的实现
STM32开发笔记112:ADS1258驱动设计——读寄存器
Internet of things development practice 18 scenario linkage: how does an intelligent light perceive light? (I) (learning notes)
Two methods to judge the storage of large and small end
Zhanrui IOT chip 8910dm is certified by Deutsche Telekom
C language implements eight sorts (1)
[nodejs] electron installation
点云读写(二):读写txt点云(空格分隔 | 逗号分隔)
Leetcode - day 2
超标量处理器设计 姚永斌 第2章 Cache --2.3 小节摘录
每日一题-1317. 将整数转换为两个无零整数的和
Nmap performs analysis of all network segment IP survivals in host detection
仅需三步学会使用低代码ThingJS与森数据DIX数据对接
Prefabricated dishes in the trillion market have also begun to roll inside. How can brands stand out in the fierce competition?
[data mining time series analysis] restaurant sales forecast
完好性简要介绍