#include
#include
int x,y[5],i,temp,k;
int main(void)
{
srand(time(NULL));
for (i=1;i<=5;i++)
{
printf("%d\n",x=rand()%10);
y[i]=x;
}
printf("\n\n");
for (i=1;i<=5;i++)
{
for (k=i;k<=5;k++)
{
if (y[i]>y[k])
{
temp=y[i];
y[i]=y[k];
y[k]=temp;
}
}
}
for (i=1;i<=5;i++)
{
printf("%d\n",y[i]);
}
return(0);
}
No comments:
Post a Comment