Skip to content

Instantly share code, notes, and snippets.

@gallirohik
Created February 25, 2018 18:50
Show Gist options
  • Save gallirohik/24882fb5b2c49e36e2f1472e6ee6b5dd to your computer and use it in GitHub Desktop.
Save gallirohik/24882fb5b2c49e36e2f1472e6ee6b5dd to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int *arr=(int *)malloc(20*sizeof(int)),count[3]={0},n,i,j;
printf("enter n:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
count[arr[i]]++;
}
for(i=0;i<n;i++)
{
if(count[j]==0)
count[j++];
arr[i]=j;
count[j]--;
}
for(i=0;i<n;i++)
printf("%d",arr[i]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment