zoukankan      html  css  js  c++  java
  • poj2685

    简单题

    View Code
    #include <iostream>
    #include <cstdlib>
    #include <cstring>
    #include <cstdio>
    using namespace std;

    #define maxl 20

    char st1[maxl], st2[maxl];

    int getd(char *st, char a)
    {
    int len = strlen(st);
    int x = -1;
    for (int i = 0; i < len; i++)
    if (st[i] == a)
    {
    x = i;
    break;
    }
    if (x == -1)
    return 0;
    if (x == 0 || st[x - 1] > '9' || st[x - 1] < '0')
    return 1;
    return st[x - 1] - '0';
    }

    int cal(char *st)
    {
    int ans = 0;
    ans += getd(st, 'm') * 1000;
    ans += getd(st, 'c') * 100;
    ans += getd(st, 'x') * 10;
    ans += getd(st, 'i');
    return ans;
    }

    void print(int a)
    {
    int b = a / 1000;
    if (b > 1)
    putchar('0' + b);
    if (b != 0)
    putchar('m');
    b = a / 100 % 10;
    if (b > 1)
    putchar('0' + b);
    if (b != 0)
    putchar('c');
    b = a / 10 % 10;
    if (b > 1)
    putchar('0' + b);
    if (b != 0)
    putchar('x');
    b = a % 10;
    if (b > 1)
    putchar('0' + b);
    if (b != 0)
    putchar('i');
    putchar('\n');
    }

    int main()
    {
    //freopen("t.txt", "r", stdin);
    int t;
    scanf("%d", &t);
    while (t--)
    {
    scanf("%s%s", st1, st2);
    int a = cal(st1);
    int b = cal(st2);
    print(a + b);
    }
    return 0;
    }

  • 相关阅读:
    H3C 配置vlan及vlan间路由
    H3C 端口安全技术
    H3C 备份系统应用程序与文件
    H3C 类似于Linux编辑命令
    H3C telnet
    H3C基本命令
    Python里的目录
    Python 模块
    Python 函数
    JS 100内与7相关的数
  • 原文地址:https://www.cnblogs.com/rainydays/p/2199610.html
Copyright © 2011-2022 走看看