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了一次,题水我更水,附ac代码#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int main() { int a[10001],b[10001]; int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d",&a[i]); b[i]=a[i]; } sort(b,b+n); int v=0; for(int i=0;i<n;i++) { if(a[i]!=b[i]) { for(int j=i+1;j<n;j++) { if(a[j]==b[i]) { swap(a[i],a[j]); v++; break; } } } } cout<<v<<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