-->
当前位置:首页 > 题库

PROGRAMMING:String sorting -- the use of string class

Luz5年前 (2021-05-10)题库498
First enter the number of strings you want to enter. Then type the set of strings on a new line. Each string ends with a carriage return, with no more than 100 characters per string.
If a string entered in the input process is "stop", the input is also ended.
Then, the input strings are sorted according to the length of each string from small to large, and the strings are output according to the sorting results. If there are multiple strings with the same length, they are output in the original input order.
###Input format:
The number of strings and the group of strings. Each string ends with '\ n'. If the input string is "stop", it also ends the input
###Output format:
There may be multiple sets of test data,
Sort all input strings by length and output them (if there is "stop", do not output "stop").
###Input example:
```in
four
faeruhyytrjh tjytj
hsrthts hjnshtgfhs
stop
three
htrskbns
bsartanjsf tyjndyt
nsr jj jtey
```
###Output example:
```out
faeruhyytrjh tjytj
hsrthts hjnshtgfhs
htrskbns
nsr jj jtey
bsartanjsf tyjndyt
```
###Tips:
According to the number of input strings to dynamically allocate storage space (using the new() function). Each string will be less than 100 characters.
There are many groups of test data, please use while() loop input.
###Source:
Data structure notes







answer:If there is no answer, please comment