当前位置:网站首页>字符串中字符排序 (10 分)请编写函数fun对长度为8个字符的字符串按降序排列。
字符串中字符排序 (10 分)请编写函数fun对长度为8个字符的字符串按降序排列。
2022-04-21 13:40:00 【Tomatos_baby】
请编写函数fun对长度为8个字符的字符串按降序排列。
函数接口定义:
int fun(char s[],int num);
其中 s 和 num 都是用户传入的参数。 函数对长度为num的字符串s按降序排列。
裁判测试程序样例:
#include<stdio.h>
int fun(char s[],int num);
int main()
{ char s[10];
gets(s);
fun(s,8);
printf("%s\n",s);
return 0;
}
/* 请在这里填写答案 */
输入样例:
azxscdvf
输出样例:
zxvsfdca
int fun(char s[],int num)
{
int i,j,plag;
for(i=0;i<num;i++)
{
for(j=0;j<i;j++)
{
if (s[i] > s[j])
{
s[i] = s[j] + s[i];
s[j] = s[i] - s[j];
s[i] = s[i] - s[j];
}
}
}
}
版权声明
本文为[Tomatos_baby]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Tomatos_baby/article/details/124318052
边栏推荐
- Longest ascending subsequence (2) (greedy + dichotomy)
- 北京大学ACM Problems 1008:Maya Calendar
- leetcode:513. 找树左下角的值【简单bfs找每层第一个】
- [digital signal processing] correlation function (energy signal | cross correlation function of energy signal | autocorrelation function of energy signal)
- Basic practice questions and answers of economic law in 2022 primary accounting title examination
- 暴力匹配阈值的基准细胞检测方案
- Installing and configuring canal
- What are the futures varieties of agricultural products?
- String count (convert to base)
- Wang Baiping: my way to envoy maintainer
猜你喜欢

Basic practice questions and answers of economic law in 2022 primary accounting title examination

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

json-server的使用

Which brand of running headphones is good and suitable for sports

In office word 2016, omml2mml appears when the formula edited by word's own formula editor is transferred to MathType Solutions to XSL problems

一份很棒的外设驱动库!(基于STM32F4)

暴力匹配阈值的基准细胞检测方案

Tailwind core concept - responsive design

Exercise questions and answers of quality, investment and progress control in 2022 supervision engineer examination

Ali Tianchi competition -- street view character coding recognition
随机推荐
Longest common subsequence (I) (dynamic gauge)
Upgrade the jdbc driver to version 8.0.28 and connect the pit record of MySQL
完成数亿元融资后,毫末智行计划超百城落地城市智能驾驶产品
Nmap usage
Wang Baiping: my way to envoy maintainer
农产品期货品种有哪些呢?
Last online class can be "distracted" by AI analysis. Intel's emotional detection AI is on fire
[digital signal processing] correlation coefficient (concept of correlation coefficient | energy signal and power signal | causality of system)
After the completion of hundreds of millions of yuan of financing, smart bank plans to land urban intelligent driving products in more than 100 cities
海口等保测评公司有几家?具体在哪里?哪里可以查到?
no server suitable for synchronization found
Open mmlab / mmpose installation and use tutorial
AI video cloud vs narrowband HD, who is the darling of the video era
STM32 drives st7789v2 TFT screen
一文读懂Faster RCNN
Work function of boost ASIO
Idea automatically generates unit test classes
[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
How to install the database of Dameng 8 version in Kirin V10 SP2
實現隨機標簽,字體大小、顏色隨機顯示