当前位置:网站首页>String string dynamic change (10 points): in the following procedures, the function of fun is to find the character with the largest ASCII code value in the string STR, move all the characters before
String string dynamic change (10 points): in the following procedures, the function of fun is to find the character with the largest ASCII code value in the string STR, move all the characters before
2022-04-21 13:40:00 【Tomatos_ baby】
In the following procedure , function fun The function is : In string str To find out in the ASCII The character with the largest code value , Move all the characters before this character one position backward in sequence , Then put the character in the first position .
Function interface definition :
void fun(char *p);
among p Is the parameter passed in by the user . Function to find p In the string indicated by the pointer ASCII The character with the largest code value , Move all the characters before this character one position backward in sequence , Then put the character in the first position .
Sample referee test procedure :
#include<stdio.h>
void fun(char *p);
int main()
{ char str[80];
gets(str);
fun(str);
printf("The string after moving:");puts(str);
return 0;
}
/* Please fill in the answer here */
sample input :
Fill in a set of inputs here
ABCDeFG
sample output :
The string after moving:eABCDFG
void fun(char* p)
{
int i=0;
char max = p[i],*j='a';
for (;p[i] != 0;i++)
{
if (p[i] > max)
{
max = p[i];
j = p+i;
}
}
while (j > p) {
*j = *(j - 1);
j--;
}
p[0] = max;
}
版权声明
本文为[Tomatos_ baby]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211340248462.html
边栏推荐
- Number II that occurs only once (hash, bit operation, logic circuit, finite state automata)
- Route selection, anti ring and re release of hcip OSPF
- News compendium of foreign Internet products last week - Angel
- 建议:ALT+X 标注已标注的区域,是否可以取消标注呢?
- 暴力匹配阈值的基准细胞检测方案
- 专家系统实例及其骨架系统
- 前馈神经网络
- 运动耳机什么样的舒服、运动健身耳机推荐
- Peking University ACM problems 1012: Maya calendar
- Ali Tianchi competition -- street view character coding recognition
猜你喜欢

海口等保测评公司有几家?具体在哪里?哪里可以查到?

Huffman coding

Longest common subsequence (I) (dynamic gauge)

Accounting practice exercises and answers for the 2022 primary accounting title examination

Leetcode: countless denominations of coins get the option of amount (DP)

Establishment of binary tree and its cueing

STM32 drives st7789v2 TFT screen

LLVM之父Chris Lattner:编译器的黄金时代

How many insurance evaluation companies are there in Haikou? Where is it specificly? Where can I find it?

leetcode:513. 找树左下角的值【简单bfs找每层第一个】
随机推荐
国际物流集运系统源码,海外仓储跨境转运系统源码
Could not load dynamic library ‘libcusolver.so.11‘
工具函数---日期格式化
SECOND: Sparsely Embedded Convolutional Detection
BOM development of access (3) BOM expansion
idea自动生成单元测类
Number II that occurs only once (hash, bit operation, logic circuit, finite state automata)
哈夫曼编码
通讯录的动态实现
滚动条样式修改
2021-2022 Guangdong Vocational College Students' professional skills competition
metasploit渗透
建议:ALT+X 标注已标注的区域,是否可以取消标注呢?
定位子元素的结构伪类
Analysis of several major reasons for the slow use of computers
完成数亿元融资后,毫末智行计划超百城落地城市智能驾驶产品
[digital signal processing] linear constant coefficient difference equation (use matlab to solve the example of "linear constant coefficient difference equation" | a vector analysis | B vector analysi
Accounting practice exercises and answers for the 2022 primary accounting title examination
颜色渐变(柱子、圆环等)
Access的BOM开发(3)BOM展开