当前位置: 代码迷 >> JavaScript >> (pojstep1.1.2)2654(直谈式模拟)
  详细解决方案

(pojstep1.1.2)2654(直谈式模拟)

热度:346   发布时间:2013-10-06 18:25:14.0
(pojstep1.1.2)2654(直叙式模拟)
/*
 * 2654_1.cpp
 *
 *  Created on: 2013年10月5日
 *      Author: Administrator
 */

#include <iostream>
#include <cstring>

using namespace std;

int main(){
	int n, k;
	int p1, p2;
	char m1[10], m2[10];
	int w[105], l[105];

	int count = 0;
	while (scanf("%d%d", &n, &k) != EOF, n) {

		if (count) {
			printf("\n");
		}
		count++;

		memset(w, 0, sizeof(w));
		memset(l, 0, sizeof(l));

		int i;
		for (i = 0; i < (k * n * (n - 1) / 2); ++i) {
			scanf("%d %s %d %s", &p1, &m1, &p2, &m2);

			if (!strcmp(m1, "rock") && !strcmp(m2, "scissors")
					|| !strcmp(m1, "scissors") && !strcmp(m2, "paper")
					|| !strcmp(m1, "paper") && !strcmp(m2, "rock")) {
				w[p1]++;
				l[p2]++;
			}

			if (!strcmp(m2, "rock") && !strcmp(m1, "scissors")
					|| !strcmp(m2, "scissors") && !strcmp(m1, "paper")
					|| !strcmp(m2, "paper") && !strcmp(m1, "rock")) {
				w[p2]++;
				l[p1]++;
			}
		}

		for(i = 1 ; i <= n ; ++i){
			if(w[i] + l[i]){
				printf("%.3lf\n",(w[i] + 0.0)/(w[i] + l[i]) );
			}else{
				printf("-\n");
			}
		}
	}
}