题目链接

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\n");
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("\n");
}
}

PAT 天梯赛 L1-054. 福到了 【字符串】的更多相关文章

  1. PAT天梯赛 L1-050 倒数第N个字符串

    题目链接:点击打开链接 给定一个完全由小写英文字母组成的字符串等差递增序列,该序列中的每个字符串的长度固定为 L,从 L 个 a 开始,以 1 为步长递增.例如当 L 为 3 时,序列为 { aaa, ...

  2. PAT 天梯赛 L1-025. 正整数A+B 【字符串处理】

    题目链接 https://www.patest.cn/contests/gplt/L1-025 思路 注意 输入字符串B的时候 要用getline 因为 可能存在空格 然后就把字符串 转化成 数字 并 ...

  3. PAT 天梯赛 L1-050. 倒数第N个字符串 【字符串】

    题目链接 https://www.patest.cn/contests/gplt/L1-050 思路 因为是求倒数 我们不如直接 倒过来看 令 zzz 为第一个字符串 我们可以理解为 十进制 转换为 ...

  4. PTA 天梯赛 L1

    L1-002 打印沙漏 细节:就是在  (i>j&&i+j<r+1) 这个区间里才有空格,然后就是 for 循环   for(r=1; ;r+=2)  条件不满足之后还会再 ...

  5. PAT天梯赛 L1-049 天梯赛座位分配

    题目链接:点击打开链接 天梯赛每年有大量参赛队员,要保证同一所学校的所有队员都不能相邻,分配座位就成为一件比较麻烦的事情.为此我们制定如下策略:假设某赛场有 N 所学校参赛,第 i 所学校有 M[i] ...

  6. PAT天梯赛L3-007 天梯地图

    题目链接:点击打开链接 本题要求你实现一个天梯赛专属在线地图,队员输入自己学校所在地和赛场地点后,该地图应该推荐两条路线:一条是最快到达路线:一条是最短距离的路线.题目保证对任意的查询请求,地图上都至 ...

  7. PAT天梯赛练习题——L3-007. 天梯地图(多边权SPFA)

    L3-007. 天梯地图 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 本题要求你实现一个天梯赛专属在线地图,队员输入自己学校 ...

  8. PAT天梯赛L1-054 福到了

    题目链接:点击打开链接 "福"字倒着贴,寓意"福到".不论到底算不算民俗,本题且请你编写程序,把各种汉字倒过来输出.这里要处理的每个汉字是由一个 N x N 的 ...

  9. PAT天梯赛练习题 L3-002. 堆栈(线段树查询第K大值或主席树)

    L3-002. 堆栈 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 大家都知道“堆栈”是一种“先进后出”的线性结构,基本操作有 ...

随机推荐

  1. react native 添加mobx

    "babel-plugin-transform-decorators-legacy": "^1.3.5", "babel-preset-react-n ...

  2. va_list 简介

    原文:http://blog.sina.com.cn/s/blog_590be5290100qhxr.html va_list是一个宏,由va_start和va_end界定. typedef char ...

  3. (入门SpringBoot)SpringBoot配置全局异常(五)

    Spring的全局异常,用于捕获程序员没有捕获的异常.具体请看下面代码: 1.ControllerAdvice拦截异常,统一处理.通过Spring的AOP来管理. @ControllerAdvicep ...

  4. java excel导出(基于注解)

    小白,做日志只是为了方便自己查看,能帮到别人当然更好,不喜勿喷. 上代码 依赖: <dependency> <groupId>org.apache.poi</groupI ...

  5. HDU3625 Examining the Rooms

    @(HDU)[Stirling數] Problem Description A murder happened in the hotel. As the best detective in the t ...

  6. 【ActiveMQ】2.spring Boot下使用ActiveMQ

    在spring boot下使用ActiveMQ,需要一下几个条件 1.安装并启动了ActiveMQ,参考:http://www.cnblogs.com/sxdcgaq8080/p/7919489.ht ...

  7. Debian Customer PPA RFC (by quqi99)

    作者:张华  发表于:2016-01-13版权声明:能够随意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 ( http://blog.csdn.net/quqi99 ) Pre ...

  8. 在.NET中怎样取得代码行数

    文章目的 介绍在.NET中取得代码行数的方法 代码 [STAThread] static void Main(string[] args) { ReportError("Yay!" ...

  9. vue-router钩子beforeRouteEnter函数获取到this实例

    官方文档: const Foo = { template: `...`, beforeRouteEnter (to, from, next) { // 在渲染该组件的对应路由被 confirm 前调用 ...

  10. mysql的安装、C++訪问mysql数据库、编码设置问题

    一.mysql的安装.这个相对简单,直接去官网下载mysql安装程序.就能够完毕安装过程,网上有非常多安装教程,这个没什么注意事项. 二.C++訪问mysql.主要是用到mysql定义的头文件,内部定 ...