[C](0.208)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<string.h> | |
int win( char *m1, char *m2 ) | |
{ | |
if( (m1[0] == 'r' && m2[0] == 's') || (m1[0] == 's' && m2[0] == 'p') || (m1[0] == 'p' && m2[0] == 'r') ) | |
return 1; | |
return 0; | |
} | |
int main() | |
{ | |
int n, k; | |
int print = 0; | |
while( scanf( "%d", &n ) != EOF && n != 0 ) | |
{ | |
scanf( "%d", &k ); | |
if( print ) | |
printf( "\n" ); | |
print = 1; | |
int people[105][2] = {0}; | |
int p1, p2; | |
char m1[10], m2[10]; | |
int i; | |
for( i = 0 ; i < k*n*(n-1)/2 ; i++ ) | |
{ | |
scanf( "%d%s%d%s", &p1, m1, &p2, m2 ); | |
if( win( m1, m2 ) ) | |
{ | |
people[p1][0]++; | |
people[p2][1]++; | |
} | |
else if( win( m2, m1 ) ) | |
{ | |
people[p1][1]++; | |
people[p2][0]++; | |
} | |
} | |
for( i = 1 ; i <= n ; i++ ) | |
if( people[i][0]+people[i][1] != 0 ) | |
printf( "%.3lf\n", (double)(people[i][0])/(double)(people[i][0]+people[i][1]) ); | |
else | |
printf( "-\n" ); | |
} | |
return 0; | |
} |
1 意見:
可以跟我說一下這一題的題意是甚麼嗎?我看了很久都看不懂
張貼留言