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)