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 90401304 at 2005-01-01 12:23:47 on Problem 2140
#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:
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