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 zxtregister at 2016-07-27 10:39:17 on Problem 2182
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

int N;
int cow[8010];
int cindex[8010];

using namespace std;

int main(){
	scanf("%d", &N);
	cow[1]=0;
	cindex[1]=1;
	for(int i=2;i<=N;i++){
		scanf("%d", cow+i);
		cindex[i]=i;
	}
	for(int i=1;i<=N;i++){
		for(int j=1;j<N;j++){
			if(cow[j]>=cow[j+1]){
				int tmp=cindex[j]; cindex[j]=cindex[j+1]; cindex[j+1]=tmp;
				tmp=cow[j+1]; cow[j+1]=cow[j]+1; cow[j]=tmp;
			}
		}
	}

	for(int i=1;i<=N;i++){
		cow[cindex[i]]=i;
	}

	for(int i=1;i<=N;i++){
		cout<<cow[i]<<endl;
	}
	

	return 0;
}

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