View Code of Problem 49

#include<stdio.h>
int main()
{int i,temp,n,m,l,k,g;
int zhu[10];
scanf("%d",&n);
printf("\n");
m=l=g=k=n-1;
for(i=0;n>0;n--,i++)
{	scanf("%d",&zhu[i]); }
temp=zhu[0];
for(;m>=0;m--)
	{if(temp<zhu[m])
	{temp=zhu[m];
	zhu[m]=zhu[0];
	zhu[0]=temp;}}
for(;l>0;l--)
{if(temp>=zhu[l])
{temp=zhu[l];
	zhu[l]=zhu[0];
	zhu[0]=temp;}
}for(;k>=0;k--)
	printf("%d ",zhu[g-k]);
printf("\n");
	return 0;
}

Double click to view unformatted code.


Back to problem 49