美文网首页
Euchre Results(水)

Euchre Results(水)

作者: SmYing | 来源:发表于2018-04-11 18:47 被阅读0次

    Time Limit: 2 Seconds Memory Limit: 65536 KB

    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.

    Source: East Central North America 2003, Practice

    #include <stdio.h>
    #include <math.h>
    
    int main(){
    int a[6];
    int x,y,sum;
    int i;
    while(scanf("%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]) != EOF){
        if(a[0]==0&&a[1]==0&&a[2]==0&&a[3]==0&&a[4]==0&&a[5]==0) break;
        sum = a[0]+a[1];
        for(i=0;i<=sum;i++){
            x = i;
            y = sum-i;
            if((a[0]+a[2]+a[4]+x) == (a[1]+a[3]+a[5]+y)){
                printf("Anna's won-loss record is %d-%d.\n",x,y);
            }
        }
    }
    return 0;
    } 
    

    while(scanf("%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]) != EOF){可以改为while(true){scanf("%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5])}

    相关文章

      网友评论

          本文标题:Euchre Results(水)

          本文链接:https://www.haomeiwen.com/subject/afvzhftx.html