ASCII code sorting STL exercises

Source: Internet
Author: User

ASCII code sorting time limit: 3000 MS | memory limit: 65535 KB difficulty: 2 Description input three characters (can be repeated, output the three characters in ascending order of the ASCII codes of each character. Enter N in the first line, indicating that there are N groups of test data. The next N rows Input Multiple groups of data. Each group of input data occupies one row and consists of three characters without spaces. Each group of input data is output with one line separated by a space. Sample input 3qweasdzxc sample output e q wa d SC x z set and multiset can be automatically sorted set. Repeated elements cannot be added. multiset can be [cpp] view plaincopyprint? <SPAN style = "FONT-SIZE: 14px"> # include <cstdio> # include <set> using namespace std; int main () {int test; while (scanf ("% d", & test )! = EOF) {multiset <char> set1; char c [101]; scanf ("% s", c); set1.insert (c, c + 3); int I = 0; for (multiset <char >:: iterator p = set1.begin (); p! = Set1.end (); p ++, I ++) {if (I! = 2) printf ("% c", * p); else printf ("% c \ n", * p) ;}return 0 ;}</SPAN>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.