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 <iostream.h> #include <math.h> void main(){ long n; cin>>n; long i,j,t=0,min=0,a[10000]={0},tem=0,count=0; for(i=0;i<n;i++) cin>>a[i]; for(i=0;i<n;i++){ for(min=a[i],j=i+1;j<n;j++){ if(min>a[j]){ min=a[j]; t=j; } } if(t!=i){ tem=a[i]; a[i]=a[t]; a[t]=tem; count++; } } cout<<count<<endl; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator