Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哪位高人可以给出一种快速求逆序的方法?我老是超时这是我的代码,怎么才能不让它超时呢? #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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator