<pre name="code" class="cpp">#include<stdio.h> int main() { int flag[1000]={0}; int tmp,i; //for(i=0;i<1000;i++)flag[i]=0; printf("How many numbers?\n"); scanf("%d",&tmp); while(tmp--) { scanf("%d",&i); flag[i]++; } tmp=1000; while(tmp--) { if(flag[tmp])while(flag[tmp]--)printf("%d ",tmp); } }
v2.0:
#include<stdio.h>
int main()
{
int flag[1000]={0};
int tmp,i;
//for(i=0;i<1000;i++)flag[i]=0;
printf("How many numbers?\n");
scanf("%d",&tmp);
while(tmp--)
{
scanf("%d",&i);
flag[i]++;
}
tmp=1000;
while(tmp--)
{
if(flag[tmp])while(flag[tmp]--)printf("%d ",tmp);
}
}
原文地址:http://blog.csdn.net/qq754406613/article/details/44002613