View Code of Problem 49

#include<stdio.h>
#include<math.h>
int main(){
	int n;
	int a[10000]={0};
	scanf("%d",&n);
	int i = 0,j = 0,temp = 0;
	while(i <n){
		scanf("%d",&a[i]);
		i++;
	}
	for(i=0;i<n;i++){
		temp=0;
		for(j=i+1;j<n;j++){
			if(a[i]>a[j]){
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;	
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%d ",a[i]);
	}
}

Double click to view unformatted code.


Back to problem 49