zoukankan      html  css  js  c++  java
  • poj2041

    简单题

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

    #define maxn 30

    char order[maxn];
    char st[maxn];
    int l;

    void work(char ch)
    {
    char x;
    int d;
    switch (ch)
    {
    case 'J':
    x
    = st[l - 1];
    for (int i = l - 1; i > 0; i--)
    st[i]
    = st[i - 1];
    st[
    0] = x;
    break;
    case 'C':
    x
    = st[0];
    for (int i = 0; i < l - 1; i++)
    st[i]
    = st[i + 1];
    st[l
    - 1] = x;
    break;
    case 'E':
    d
    = l / 2 + (l & 1);
    for (int i = 0; i < l / 2; i++)
    swap(st[i], st[i
    + d]);
    break;
    case 'A':
    reverse(st, st
    + l);
    break;
    case 'P':
    for (int i = 0; i < l; i++)
    if (st[i] <= '9' && st[i] >= '0')
    st[i]
    = (st[i] - '0' + 9) % 10 + '0';
    break;
    case 'M':
    for (int i = 0; i < l; i++)
    if (st[i] <= '9' && st[i] >= '0')
    st[i]
    = (st[i] - '0' + 1) % 10 + '0';
    break;
    }
    }

    int main()
    {
    //freopen("t.txt", "r", stdin);
    int t;
    scanf(
    "%d", &t);
    while (t--)
    {
    scanf(
    "%s", order);
    scanf(
    "%s", st);
    l
    = strlen(st);
    for (int i = strlen(order) - 1; i >= 0; i--)
    work(order[i]);
    printf(
    "%s\n", st);
    }
    return 0;
    }
  • 相关阅读:
    1月10日 TextView
    1月9日 布局2
    30 Adapter适配器
    29 个人通讯录列表(一)
    28 ListView控件
    27 登录模板
    26 Activity的启动模式
    25 Activity的生命周期
    24 得到Activity返回的数据
    23 Activity的传值2(bundle)
  • 原文地址:https://www.cnblogs.com/rainydays/p/2114621.html
Copyright © 2011-2022 走看看