觉得浮夸了四年,漠然发现原来是浮躁了四年!

hdu 4461(The Power of Xiangqi)

Problem webpage:

http://acm.hdu.edu.cn/showproblem.php?pid=4461

Problem analysis:
This is one of the 2012 Asia Hangzhou Regional Contest problems, what I want to say is this problem is just proved that you joined the contest;

The only problem is the problem description is too long>

After reading the problem description, you will find it's so easy;

 

复制代码
View Code
#include<stdio.h>
#include<string.h>
int canon,horse;
int power(char x)
{
    int p;
    if(x=='A')
        p=16;
    else if(x=='B')
    {
        p=7;
        horse=1;
    }
    else if(x=='C')
    {
        p=8;
        canon=1;
    }
    else if(x=='D')
        p=1;
    else if(x=='E')
        p=1;
    else if(x=='F')
        p=2;
    else
        p=3;
    return p;
}

int main()
{
    int n,num1,num2,i,j;
    char  red[20],black[20];
    
    int sum_red,sum_black;
    scanf("%d",&n);
    while(n--)
    {
        canon=horse=0;
        sum_red=sum_black=0;
        scanf("%d",&num1);
        for(i=0;i<num1;i++)
            scanf(" %c",&red[i]);
        scanf("%d",&num2);
        for(j=0;j<num2;j++)
            scanf(" %c",&black[j]);
        for(i=0;i<num1;i++)
            sum_red+=power(red[i]);
        if(horse==0||canon==0)
            sum_red-=1;
        horse=canon=0;
        for(j=0;j<num2;j++)
            sum_black+=power(black[j]);
        if(horse==0||canon==0)
            sum_black-=1;
        if(sum_red==sum_black)
            printf("tie\n");
        else if(sum_red>sum_black)
            printf("red\n");
        else if(sum_red<sum_black)
            printf("black\n");
    }
    return 0;
}






        
复制代码

 

 

posted @   heat nan  阅读(109)  评论(0编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
点击右上角即可分享
微信分享提示