Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  ??
Language: C/C++
Code:
#include<stdio.h>
int main()
{
     int N;
     scanf("%d",&N);//输入N的值 
     int i,j;
     int a[N]; 
     for(i=0;i<N;i++)
          scanf("%d",&a[i]); 



     int sum=0;//                             //
     for(i=0;i<N;i++)
     {
          if(a[i]%2==0)
               sum++;
     }





     int b[sum],k=0;
     for(i=0;i<N;i++)
     {
          if(a[i]%2==0)
          {
               b[k]=a[i];
               k++;
          }
     }//                                      //





     int c[N-sum],l=0;
     for(i=0;i<N;i++)
     {
          if(a[i]%2!=0)
          {
               c[l]=a[i];
               l++;
          }
     }




     int t;
     for(i=0;i<sum;i++)
     for(j=0;j<sum;j++)
          {
               if(b[i]<b[i+1])
               {
                    t=b[i];
                    b[i]=b[i+1];
                    b[i+1]=t;
               }
          }



     for(i=0;i<sum;i++)
     for(j=0;j<sum;j++)
          {
               if(c[i]<c[i+1])
               {
                    t=c[i];
                    c[i]=c[i+1];
                    c[i+1]=t;
               }
          }


     for(i=0;i<sum;i++)
          printf("%d ",b[i]);
     for(i=0;i<N-sum;i++)
          printf("%d ",c[i]);
}
Comments: