View Code of Problem 49

#include<stdio.h>
#include<string.h>
int main(){
	int n;
	scanf("%d",&n);
	int i,j,t;
	int a[10];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(a[i]<a[j]){
				t=a[i];
				a[i]=a[j];
				a[j]=t;
			}
		}
	}
		for(i=0;i<n;i++){
			if(i!=(n-1))
		printf("%d ",a[i]);
			else
printf("%d",a[i]);
	}
		printf("\n");
}

Double click to view unformatted code.


Back to problem 49