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 20061463 at 2014-03-02 21:04:26 on Problem 1012
#include <iostream>
#include <vector>
using namespace std;

void printGuys(vector<int> guys) {
	int i = 0, size = guys.size();
	for (i = 0; i < size; ++i) {
		printf("i:%d guy:%d\t", i, guys[i]);
	}
	printf("\n");
}

void test() {
	vector<int> guys(6, 0);
	int n = 6, m = 5;

	int i = 0, next = 0, size = n;
	for (i = 0; i < n; ++i) {
		guys[i] = i + 1;
	}
	while (guys.size() > 1) {
		size = guys.size();
		next = (next + m - 1) % size;
		printf("\n next:%d\t guy:%d size:%d\n", next, guys[next], size);
		printGuys(guys);
		for (i = next; i < size - 1; i++) {
			guys[i] = guys[i + 1];
		}
		guys.pop_back();
	}
	printGuys(guys);
}

int main(void) {
	test();
//	freopen("input.txt", "r", stdin);
         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