zoukankan      html  css  js  c++  java
  • PAT 天梯赛 L1-054. 福到了 【字符串】

    题目链接

    https://www.patest.cn/contests/gplt/L1-054

    思路
    可以先将字符串用字符串数组 输入
    然后用另一个字符串数组 从 n - 1 -> 0 保存 其反转的字符串

    然后每一行比较一下 这两个字符串数组有没有什么不同 如果没有 就要输出 bu yong dao le

    然后最后 输出“到了” 的字符串 注意 字符替换

    AC代码

    #include <cstdio>
    #include <cstring>
    #include <ctype.h>
    #include <cstdlib>
    #include <cmath>
    #include <climits>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <deque>
    #include <vector>
    #include <queue>
    #include <string>
    #include <map>
    #include <stack>
    #include <set>
    #include <numeric>
    #include <sstream>
    #include <iomanip>
    #include <limits>
    
    #define CLR(a) memset(a, 0, sizeof(a))
    #define pb push_back
    
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef pair <int, int> pii;
    typedef pair <ll, ll> pll;
    
    const double PI  = 3.14159265358979323846264338327;
    const double E   = exp(1);
    const double eps = 1e-6;
    
    const int INF  = 0x3f3f3f3f;
    const int maxn = 1e2 + 5;
    const int MOD  = 1e9 + 7;
    
    string in[maxn], tran[maxn];
    
    string Reverse(string s)
    {
        string ans = "";
        int len = s.size();
        for (int i = len - 1; i >= 0; i--)
            ans += s[i];
        return ans;
    }
    
    int main()
    {
        char c;
        int n;
        scanf(" %c%d", &c, &n);
        getchar();
        for (int i = 0; i < n; i++)
        {
            getline(cin, in[i]);
            tran[n - 1 - i] = Reverse(in[i]);
        }
        int flag = 1;
        for (int i = 0; i < n; i++)
        {
            if (in[i] != tran[i])
            {
                flag = 0;
                break;
            }
        }
        if (flag)
            printf("bu yong dao le
    ");
        for (int i = 0; i < n; i++)
        {
            int len = tran[i].size();
            for (int j = 0; j < len; j++)
            {
                if (tran[i][j] != ' ')
                    printf("%c", c);
                else
                    printf(" ");
            }
            printf("
    ");
        }
    }
  • 相关阅读:
    Checking Types Against the Real World in TypeScript
    nexus pip proxy config
    go.rice 强大灵活的golang 静态资源嵌入包
    几个golang 静态资源嵌入包
    rpm 子包创建学习
    Rpm Creating Subpackages
    ava 类似jest snapshot 功能试用
    ava js 测试框架基本试用
    The Architectural Principles Behind Vrbo’s GraphQL Implementation
    graphql-compose graphql schema 生成工具集
  • 原文地址:https://www.cnblogs.com/Dup4/p/9433168.html
Copyright © 2011-2022 走看看