zoukankan      html  css  js  c++  java
  • PAT 团体程序设计天梯赛-练习集 L1-019. 谁先倒

    给出甲、乙两人的酒量(最多能喝多少杯不倒)和划拳记录,请你判断两个人谁先倒。

    输入格式:

    输入第一行先后给出甲、乙两人的酒量(不超过100的非负整数),以空格分隔。下一行给出一个正整数N(<=100),随后N行,每行给出一轮划拳的记录,格式为:

    甲喊 甲划 乙喊 乙划

    其中“喊”是喊出的数字,“划”是划出的数字,均为不超过100的正整数(两只手一起划)。

    输出格式:

    在第一行中输出先倒下的那个人:A代表甲,B代表乙。第二行中输出没倒的那个人喝了多少杯。题目保证有一个人倒下。注意程序处理到有人倒下就终止,后面的数据不必处理。

    输入样例:

    1 1
    6
    8 10 9 12
    5 10 5 10
    3 8 5 12
    12 18 1 13
    4 16 12 15
    15 1 1 16
    

    输出样例:

    A
    1
    
     1 #include<iostream>
     2 #include<stdio.h>
     3 using namespace std;
     4 int main()
     5 {
     6     int jia,yi;
     7     cin>>jia>>yi;
     8     int jiahe=0,yihe=0;
     9     int jiahan,jiahua,yihan,yihua;
    10     int T;
    11     cin>>T;
    12     bool flag;//1是甲赢,0是乙赢
    13     while(T--)
    14     {
    15         cin>>jiahan>>jiahua>>yihan>>yihua;
    16         if(jiahua==jiahan+yihan&&yihua!=jiahan+yihan)jiahe++;
    17         else if(yihua==jiahan+yihan&&jiahua!=jiahan+yihan)yihe++;
    18         if(jiahe>jia)
    19         {
    20             flag=0;
    21             break;
    22         }
    23         if(yihe>yi)
    24         {
    25             flag=1;
    26             break;
    27         }
    28     }
    29     if(flag)
    30     {
    31         printf("B
    %d
    ",jiahe);
    32     }
    33     else 
    34         printf("A
    %d
    ",yihe);
    35     return 0;
    36 }

  • 相关阅读:
    Application.Current的使用
    .NET中资源文件的使用
    PMP模拟试题与解析(七)
    PMP模拟试题与解析(四)
    RMAN命令简介
    数据库备份和恢复概述
    ORA-14402: updating partition key column would cause a partition change
    RMAN概述
    PLS-00642: local collection types not allowed in SQL statements
    SFTP(Secure File Transfer Protocol)安全的文件传输协议的使用
  • 原文地址:https://www.cnblogs.com/Annetree/p/5669435.html
Copyright © 2011-2022 走看看