Problem Statement:
Given the list of numbers, you are to sort them in non decreasing order.
Input
t – the number of numbers in list, then t lines follow [t <= 10^6].Each line contains one integer: N [0 <= N <= 10^6]
Output
Output given numbers in non decreasing order.Example
Input:5
5
3
6
7
1Output:
1
3
5
6
7
Solution:
#include<stdio.h>
int main()
{
int i,num,arr[1000001]={0},n;
scanf("%d",&num);
for(i=0;i<num;i++)
{
scanf("%d",&n);
arr[n]++;
}
for(i=0;i<1000001;i++)
if(arr[i])
while(arr[i]--)
printf("%d\n",i);
return 0;
}
Thanks!!!
ReplyDeletecould you explain the program please?
ReplyDeleteyeah i cant understand
ReplyDelete