Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does C++ find the longest connection path of a string?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to find the longest connection path of a string in C++". The content in the article is simple and clear, and it is easy to learn and understand. Now please follow the editor's train of thought slowly and deeply. Let's study and learn how C++ finds the longest connection path for strings.

Topic description

Given n strings, please arrange the n strings in dictionary order.

Enter a description:

Enter a positive integer n (1 ≤ n ≤ 1000) for the first behavior, and the following n acts as n strings (string length ≤ 1000), which contains only uppercase and lowercase letters.

Output description:

The data output is n lines, and the output is a string arranged in dictionary order.

Example

Input

nine

Cap

To

Cat

Card

Two

Too

Up

Boat

Boot

Output

Boat

Boot

Cap

Card

Cat

To

Too

Two

Up

Analysis

To be honest, I didn't know this question would be called by that name on the Internet. Xiaobai thinks it should be called dictionary sorting. But it just so happens that the buddies can familiarize themselves with the associated container with Xiaobai. The data stored in the set association container itself is sorted in dictionary order, so we only need to input the data and read it sequentially to meet the requirements.

However, this question rookie encountered a problem during the test, that is, the pass rate was only 60%. Looking at the course of failure, it was found that there was a test data that contained two duplicate strings. So we need to use multiset to associate the container. This container allows duplicates of stored data and will save all of it, unlike the set container, which is saved only once. It's all in # include.

Code

# include

# include

# include

Using namespace std

Int main ()

{

Int index

While (cin > > index)

{

Multiset str_set

For (int itemositti > str)

Str_set.insert (str)

}

For (auto m:str_set)

Cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report