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 |
同崩溃!!WA哭我直接用的选择排序+计数。。还是WA!!!!!想不通。。好心人帮忙看看。。谢谢拉 #include <iostream> #include <cstdio> using namespace std; long t,n; long data[10011]; long ans; int main() { long i,temp,j,k; cin>>t; for (i=1;i<=t;i++) { cin>>n; for (i=1;i<=n;i++) scanf("%d",&data[i]); ans=0; for (i=1;i<=n;i++) if (data[i]!=i) { for (j=i+1;j<=n;j++) if (data[j]==i) break; temp=data[i]; data[i]=data[j]; data[j]=temp; ans++; } cout<<ans<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator