额。
输入整型数组和排序标识,对其元素按照升序或降序进行排序
http://www.nowcoder.com/questionTerminal/dd0c6b26c9e541f5b935047ff4156309
include<stdio.h>
include<math.h>
int main()
{
int val;
while(scanf("%d", &val) != EOF)
{
int *str = (int *)malloc(val * sizeof(int));
int i;
for(i = 0; i < val; i++)
scanf("%d", &str[i]);
int str2[100000]={0};
for(i = 0; i < val; i++)
{
str2[str[i]]++;
}
int flag;
scanf("%d", &flag);
if(flag == 0)
{
for(i = 0; i < 100000; i++)
{
while(str2[i] != 0)
{
printf("%d ", i);
str2[i]--;
}
}
}
if(flag == 1)
{
for(i = 99999; i >= 0; i--)
{
while(str2[i] != 0)
{
printf("%d ", i);
str2[i]--;
}
}
}
printf("\n");
free(str);
}
system("pause");
return 0;
}