Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

帮帮忙,不知道哪错了啊

Posted by meifang at 2011-08-11 11:03:32
#include<stdio.h>
 //#include<windows.h> 
int main()
{ 
     int n,a[1000],b[1000],i,j;
     scanf("%d",&n);
     for(i=0;i<n;i++)
     {
         scanf("%d",&a[i]);
		 b[i]=i;
     }
     for(i=0;i<n;i++)
     { 
         for(j=i+1;j<n;j++)
         {
              if(a[b[j]]<a[b[i]])
              {int t=b[j];

			   b[j]=b[i];
			   b[i]=t;
			  }
         }
         //printf("%d ",b[i]);
     }
     int max=0,count;
     for(i=0;i<n;i++)
     {
         j=0;count=1;
         while(b[j]!=n-1)
         {if(b[j]>=b[j-1]&&b[j]<=n-1)
             count++;j++;
         }
         if(count>max)
             max=count;
     }
     printf("%d\n",max);    
     //system("pause");
     return 0; 
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator