PAT1018

1018. 锤子剪刀布 (20)

时间限制
100 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue

大家应该都会玩“锤子剪刀布”的游戏:两人同时给出手势,胜负规则如图所示:

现给出两人的交锋记录,请统计双方的胜、平、负次数,并且给出双方分别出什么手势的胜算最大。

输入格式:

输入第1行给出正整数N(<=105),即双方交锋的次数。随后N行,每行给出一次交锋的信息,即甲、乙双方同时给出的的手势。C代表“锤子”、J代表“剪刀”、B代表“布”,第1个字母代表甲方,第2个代表乙方,中间有1个空格。

输出格式:

输出第1、2行分别给出甲、乙的胜、平、负次数,数字间以1个空格分隔。第3行给出两个字母,分别代表甲、乙获胜次数最多的手势,中间有1个空格。如果解不唯一,则输出按字母序最小的解。

输入样例:
10
C J
J B
C B
B B
B C
C C
C B
J B
B C
J J
输出样例:
5 3 2
2 3 5
B B
package com.lwh.agrithmatic.paractice;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Practise13{
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    String[] a=new String[n];
    String [] b=new String[n];
    for(int i=0;i<n;i++){
      String input=br.readLine();
      a[i]=input.split(" ")[0];
      b[i]=input.split(" ")[1];
    }
    int awintime=0;
    int bwintime=0;
    int equal=0;
    int ac=0;
    int aj=0;
    int ab=0;
    int bc=0;
    int bj=0;
    int bb=0;
    for(int i=0;i<n;i++){
      
      if(a[i].equals("C")){
        if(b[i].equals("J"))
        {
          awintime++;
          ac++;
        }else if(b[i].equals("B")){
          bwintime++;
          bb++;
        }else{
          equal++;
        }
      }
        
      if(a[i].equals("J")){
        if(b[i].equals("B")){
          awintime++;
          aj++;
        }else if(b[i].equals("C")){
          bwintime++;
          bc++;
        }else{
          equal++;
        }
      }
      if(a[i].equals("B")){
        if(b[i].equals("C")){
          awintime++;
          ab++;  
        }else if(b[i].equals("J")){
          bwintime++;
          bj++;
        }else{
          equal++;
        }
      }
    }
    
    System.out.println(awintime+" "+equal+" "+(n-awintime-equal));
    System.out.println(bwintime+" "+equal+" "+(n-bwintime-equal));
    int maxa=ab;
    int maxb=bb;
    String taga="B";
    if(ac>maxa){
      maxa=ac;
      taga="C";
    } 
    if(aj>maxa){
      maxa=aj;
      taga="J";
    }
    String tagb="B";
    if(bc>maxb){
      maxb=bc;
      tagb="C";
    }
    if(bj>maxb){
      maxb=bj;
      tagb="J";
    }
   System.out.println(taga+" "+tagb);
  }

}

 

转载于:https://www.cnblogs.com/wenhulu/p/6307444.html

function copy-data([int]$startrow, [int]$startcol, [int]$endrow, [int]$endcol, [string]$pat, [string]$file, [int]$sheetfrom, [int]$sheetto) { $excel = New-Object -ComObject Excel.Application $excel.Visible = $false $wb = $excel.Workbooks.Open($file) $wsfrom = $wb.Sheets.Item($sheetfrom) $wsto = $wb.Sheets.Item($sheetto) $sr = $wsfrom.Range($wsfrom.Cells.Item($startrow, $startcol), $wsfrom.Cells.Item($endrow, $endcol)) $fc = $sr.Find($pat) if ($fc -ne $null) { $rown = $fc.Row $dsr = $wsto.Range($wsto.Cells.Item($rown, $startcol), $wsto.Cells.Item($rown + ($endrow - $startrow), $endcol)) $dsr = $dsr.Resize($sr.Rows.Count, $sr.Columns.Count) $sr.Copy() $dsr.PasteSpecial(-4104) } $excel.DisplayAlerts = $false $wb.Close($true) [Runtime.Interopservices.Marshal]::ReleaseComObject($excel) | Out-Null } $path = $PWD.Path $file = "$path\a.xlsx" # 将sheet1中第1行到第4行、第2列到第9列的数据复制到sheet2中 copy-data -startrow 1 -startcol 2 -endrow 4 -endcol 9 -pat 1009 -file $file -sheetfrom 1 -sheetto 2 # 将sheet1中第6行到第8行、第2列到第9列的数据复制到sheet2中 copy-data -startrow 6 -startcol 2 -endrow 8 -endcol 9 -pat 1018 -file $file -sheetfrom 1 -sheetto 2 # 将sheet1中第10行到第11行、第2列到第9列的数据复制到sheet2中 copy-data -startrow 10 -startcol 2 -endrow 11 -endcol 9 -pat 1023 -file $file -sheetfrom 1 -sheetto 2 这个是搜索sheet1中关键词吗,我现在要搜索sheet2中关键词 得到行信息后再把sheet1指定内容复制到sheet2指定区域,怎么修改呢
最新发布
05-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值