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 wwwwwwking at 2007-12-25 16:14:44 on Problem 2299
这是我的代码,怎么才能不让它超时呢?

#include <stdio.h>
#include <string.h>
int main ()
{
    int a[10000]={0};
    int n,t,m,i,j;
    for (;;)
    {
        t=0;
        scanf ("%d",&m);
        if (m==0) break;
        for (i=0;i<m;++i)
        {
            scanf ("%d",&a[i]);
        }
        for (i=0;i<m-1;++i)
        {
             for (j=i+1;j<m;++j)
             if (a[j]<a[i]) ++t;   
        }
        printf ("%d\n",t);
    }
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