当前位置:网站首页>Exercise 5.14 input n strings, arrange them in alphabetical order and output them.
Exercise 5.14 input n strings, arrange them in alphabetical order and output them.
2022-06-13 01:07:00 【Python's path to becoming a God】
exercises 5.14 Input n A string , Arrange them in alphabetical order and output .
Code :
#include<iostream>
using namespace std;
int main()
{
const int N = 5;
int i,j,min_i;
string str[N],min;
cout << " Please enter five strings :" << endl;
for (i = 0; i != N; ++i)
{
cin >>str[i];
}
for (i = 0; i != N; ++i) // Selection sort
{
min = str[i];
min_i = i;
for (j = i + 1; j != N; ++j)
{
if (str[j] < min)
{
min = str[j];
min_i = j;
}
}
str[min_i] = str[i];
str[i] = min;
}
cout << " In descending order :" << endl;
for (i = 0; i != N; ++i)
{
cout << str[i] << endl;
}
return 0;
}
边栏推荐
- Five classic articles worth reading (2)
- What kind of experience is it to be a software test engineer in a state-owned enterprise: every day is like a war
- gpu加速pytorch能用吗?
- Kotlin collaboration, the life cycle of a job
- The seventh finals of the Blue Bridge Cup
- Pipeline流水线项目构建
- Deep learning model pruning
- Expression tree - medium order printout
- 单片机串口中断以及消息收发处理——对接受信息进行判断实现控制
- 软件测试的几种分类,一看就明了
猜你喜欢

How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of strategic returns of vrsi, bbiboll, WR, bias and RSI indicators

Pipeline pipeline project construction

Common skills of quantitative investment - index part 2: detailed explanation of BOL (Bollinger line) index, its code implementation and drawing

Ecological convergence NFT attacks, metaverse ape leads the new paradigm revolution of Web 3.0 meta universe

How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of DBCD, ROC, vroc, Cr and psy index strategy income

在国企做软件测试工程师是一种什么样的体验:每天过的像打仗一样

Binary tree -- using hierarchical sequence and middle sequence to determine a tree

ArrayList underlying source code

How many rounds of deep learning training? How many iterations?

gpu加速pytorch能用吗?
随机推荐
Wikipedia User Guide
Leetcode-13- Roman numeral to integer (simple)
深度学习训练多少轮?迭代多少次?
论文笔记:STMARL: A Spatio-Temporal Multi-AgentReinforcement Learning Approach for Cooperative Traffic
Common skills of quantitative investment -- Drawing Part 1: Drawing stock closing price curve and ochl candle chart
生态聚合NFT来袭,Metaverse Ape引领Web 3.0元宇宙新范式革命
What kind of experience is it to be a software test engineer in a state-owned enterprise: every day is like a war
Traditional machine learning classification model predicts the rise and fall of stock prices under more than 40 indicators
Pysmb usage
The scope builder coroutinescope, runblocking and supervisorscope of kotlin collaboration processes run synchronously. How can other collaboration processes not be suspended when the collaboration pro
Rasa对话机器人之HelpDesk (三)
Today's sleep quality record 74 points
Et5.0 simply transform referencecollectorieditor
Key point detection data preparation and model design based on u-net Network -- detection model of four key points of industrial components
Introduction to ROS from introduction to mastery (zero) tutorial
leetcode 206. Reverse linked list
Remove duplicates from an ordered array
Leetcode-78- subset (medium)
Breadth first search for node editor runtime traversal
Binary tree traversal - recursive and iterative templates