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;
    }
  • 相关阅读:
    关于《iBoard 电子学堂》的学习及进阶方式(精 转)
    OV7670 RAW输出 bayer 解码
    yuv和yCbCr的差异
    LeetCode--Anagrams
    LeetCode--N-Queens
    LeetCode--Gas Station
    GDB调试(转)
    LeetCode--Word Search
    Ptrace_scope的作用及设置
    LeetCode--Gray Code
  • 原文地址:https://www.cnblogs.com/rainydays/p/2114621.html
Copyright © 2011-2022 走看看