1023 组个最小数

来源:互联网 发布:阿里云重装系统在哪里 编辑:程序博客网 时间:2024/06/06 00:57
#include<stdio.h>void QuickSort(int a[],int low,int high);int main(){  int a[50];  int i=0,j=0,k=0;  int n;  for(i=0;i<10;i++)  {    scanf("%d",&n);    for(j=0;j<n;j++)    {      a[k]=i;      k++;    }  }  k--;  QuickSort(a,0,k);  if(a[0]!=0)  {    for(i=0;i<=k;i++)      printf("%d",a[i]);  }  else  {    for(i=0;a[i]==0;i++) ;    a[0]=a[i];    a[i]=0;    for(i=0;i<=k;i++)      printf("%d",a[i]);  }  return 0;}void QuickSort(int a[],int low,int high){  if(low>=high) return ;  int temp=a[low];  int first=low;  int last=high;  while(first < last)  {  while(first < last && a[last]>=temp) last--;  a[first]=a[last];  while(first < last && a[first]<=temp) first++;  a[last]=a[first];  }  a[first]=temp;  QuickSort(a,low,first-1);  QuickSort(a,first+1,high);}
0 0
原创粉丝点击