#include
void main()
{ int n,a[100],i,j,temp;
scanf("%d",&n);//输入数据的个数
for ( i=0;iscanf("%d",&a[i]); //循环输入每个数据
for ( i=0;ifor ( j=i;j if ( a[j]>a[j+1] ) //冒泡排序法,升序排列
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
for ( i=0;iprintf("%d ",a[i]);
printf("\n");
for ( i=n-1;i>=0;i-- )//降序输出
printf("%d ",a[i]);
printf("\n");
}
输出示例:
若有疑问,请追问
#inlcude
void main()
{ int n,a[100],i,j,k;
scanf("%d",&n);
for ( i=0;i
for ( i=0;i
for ( i=0;i