Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
581 B
3
Indexable
#include <stdio.h>
int main()
{
	int n, i, j, aux, v[1000], maxi;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &v[i]);
	maxi = v[0];
	for (i = 0; i < n; i++) 
	{
		if (v[i] > maxi)
			maxi = v[i];
	}
	for (i = 0; i < maxi - 1; i++)
		for (j = i + 1; j < maxi; j++)
			if (v[i] > v[j])
			{
				aux = v[i];
				v[i] = v[j];
				v[j] = aux;
			}
	for (i = maxi; i < n - 1; i++)
		for (j = i + 1; j < n; j++)
			if (v[i] < v[j])
			{
				aux = v[i];
				v[i] = v[j];
				v[j] = aux;
			}
	for (i = 0; i < n; i++)
		printf("%d", v[i]);

}