首页 > 代码库 > 比大小

比大小

#include<stdio.h>int main (){  #ifdef ONLINE_JUDGE  #else  freopen ("in.txt","r",stdin);  #endif  int  n,m;  int  a[101];  while(scanf("%d",&n)!=EOF&&(n<100&&n!=0)){     for (int  i=0;i<n;++i)        scanf("%d",&a[i]);     for (int  i=0;i<n;++i)     for (int  k=0;k<n-i;++k)     if(a[k]>a[k+1])     {         m=a[k];         a[k]=a[k+1];         a[k+1]=m;     }     for (int  i=0;i<n;++i)      printf("%d ",a[i]);      printf("\n");}  return 0;}

 

比大小