Anna, Betty, Cindy and Zelda like playing the card game Euchre. Euchre is a game for two teams of two, and each time they meet the girls split off into different teams. They also keep overall records of the number of games each player has won and lost. Anna has misplaced her won-loss results, but she does have the results of the other three players. Given this, she figures she can determine her won-loss record.
Input
Input will consist of multiple problem instances. Each instance will consist of a single line containing six integers. The first two are the number of wins and losses (respectively) for Betty, the next two are the number of wins and losses for Cindy and the last two are the number of wins and losses for Zelda. A final line of six zeroes will terminate input and should not be processed.
Output
For each problem instance, output a single line indicating Anna's won-loss record, in the format shown in the example below.
Sample Input
10 3 6 7 8 5
1874 2945 2030 2789 1025 3794
0 0 0 0 0 0
Sample Output
Anna's won-loss record is 2-11.
Anna's won-loss record is 4709-110.
题意:4个人任意分成2队进行比赛,然后根据其他3个人输赢的情况,得出Anna的输赢情况
思路:每个人的赢和输加起来一样多。
代码:
#include <stdio.h>
int main()
{
int a[6];
while(1)
{
int i,t=0;
int sum;
for(i=0;i<6;i++)
{
scanf("%d",&a[i]);
if(a[i]==0)
t++;
}
if(t==6)
break;
sum=a[0]+a[1];
sum=2*sum;
printf("Anna's won-loss record is %d-%d.\n",sum-a[0]-a[2]-a[4],sum-a[1]-a[3]-a[5]);
}
return 0;
}
本文介绍了一个算法问题,即如何通过已知三位玩家的胜负记录来推算第四位玩家Anna的胜负记录。该问题源于一种四人两队的纸牌游戏Euchre,通过对输入数据的数学处理,可以准确计算出Anna的胜负次数。

137

被折叠的 条评论
为什么被折叠?



