PAT1018

#include <bits/stdc++.h>

using namespace std;
char action[] = {'C','J','B'};
int node[3][3] = {{0,1,-1},
                  {-1,0,1},
                  {1,-1,0}};

int Action(char c){
    for(int i = 0;i<3;i++){
        if(action[i] == c){
            return i;
        }
    }
    return 0;
}

vector<char>ans1;
vector<char>ans2;

int main() {
    int n,n1;
    char c1,c2;
    int a,b;
    int success=0,same=0,fail = 0;
    int count1[3] = {0,0,0};
    int count2[3] = {0,0,0};
    cin>>n;
    n1 = n;
    while (n1--){
        cin>>c1>>c2;
        a = Action(c1);
        b = Action(c2);
        if(node[a][b] == 1){
            success++;
            count1[a]++;
        }else if(node[a][b] == 0){//平局
            same++;
        }
        else{
            count2[b]++;
        }
    }
    int a1 = max(max(count1[0],count1[1]),count1[2]);//赢的最多的手势
    int a2 = max(max(count2[0],count2[1]),count2[2]);
    cout<<success<<" "<<same<<" "<<n-success-same<<endl;
    cout<<n-success-same<<" "<<same<<" "<<success<<endl;
    for(int i = 0;i<3;i++){
        //cout<<count1[i]<<" ";
        if(count1[i] == a1) {
            ans1.push_back(action[i]);
        }if(count2[i] == a2) {
            ans2.push_back(action[i]);
        }
    }
    sort(ans1.begin(),ans1.end());
    sort(ans2.begin(),ans2.end());
    cout<<ans1[0]<<" "<<ans2[0];
    return 0;
}
/**
10
C J
J B
C B
B B
B C
C C
C B
J B
B C
J J
**/

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
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、付费专栏及课程。

余额充值