Sequence of basic practice sequences (use of sort)

Source: Internet
Author: User

Basic Practice Sequence Sequencing

Time limit: 1.0s memory limit: 512.0MB The problem description is given a sequence of length n, which arranges the sequence in small to large order. 1<=N<=200 input format first behavior an integer n.
The second row contains n integers, and the absolute value of each integer is less than 10000 for the number to be sorted. Output format output one line, the sorted sequence is output in order from small to large. Sample Input 5
8 3 6 4 9 Sample output 3 4 6 8 9 Analysis:Sorting can be achieved through the sort in STL sort (A, A+n, less<int> ())Sort an array of type int in ascending order sort (A, A+n, greater<int> ())The C + + code implementation (AC) is arranged in descending order of type a array of int:
1#include <iostream>2#include <algorithm>3#include <cstring>4#include <cstdio>5#include <cmath>6#include <stack>7#include <map>8#include <queue>9 Ten using namespacestd; One  A intMain () - { -     intN, a[ About]; thescanf"%d", &n); -      for(inti =0; I < n; ++i) -scanf"%d", &a[i]); -Sort (A, a+n, less<int>()); +      for(inti =0; I < n; ++i) -printf"%d", A[i]); +printf"\ n"); A     return 0; at}

Sequence of basic practice sequences (use of sort)

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.