Lanqiao Cup---basic practice sequence sorting (basic use of sort)

Problem Description

  Given a sequence of length n, arrange this sequence in ascending order. 1<=n<=200

Input format

  The first line is an integer n.
  The second line contains n integers, which are the numbers to be sorted, and the absolute value of each integer is less than 10000.

Output format

  Output a row, and output the sorted sequence in ascending order.

Sample input

5
8 3 6 4 9

Sample output

3 4 6 8 9

 

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	int a[1010];
	scanf("%d", &n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	for(i=0;i<n;i++)
	printf("%d ",a[i]);
	return 0;
}

 

Guess you like

Origin blog.csdn.net/with_wine/article/details/114919821