PAT 天梯赛 L1-054. 福到了 【字符串】
2024-09-30 02:28:25
题目链接
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");
}
}
最新文章
- SQL Server 通过备份文件初始化复制
- Linux权限管理.md
- Redis开启持久化
- jqGrid动态列
- [安卓]AndroidManifest.xml文件简介及结构
- LR回放测试脚本
- 个人比较喜欢的Sublime Text主题
- LBS配置
- 关于require,require_once,include和include_once的区别
- IM 融云 之 列表及封装
- C语言第六周博客作业--数据类型
- 在Windows上使用Let加密IIS
- Spring Boot 2.x (十):构建优雅的RESTful接口
- 剖析epoll机制
- python 打印堆栈信息方法
- topcoder srm 325 div1
- 2017-2018-2 20165306 实验三《敏捷开发与XP实践》实验报告
- Could not find method google() for arguments [] on repository container.
- PHPUnit 组织测试
- Redis学习系列五Set(集合)
热门文章
- LeetCode OJ--Add Two Numbers
- AC日记——dispatching bzoj 2809
- Tarjan缩点+DAG图dp
- 笔记-迎难而上之Java基础进阶4
- GridControl 校验输入单元格格式 z
- 托管和非托管转换新方法:Marshaling Library(zz) 【转】
- 【翻译自mos文章】检查$ORACLE_HOME是否是RAC的HOME的方法以及relink RAC的Oracle binary的方法
- CentOS6.5_64bit下编译安装MySQL-5.6.23
- vue 给组件绑定原生事件
- 工作总结 mvc 调页面传参数 参数值会一直保存 在这个页面上的