Translation
【摘要】
文章目录
一、Translation总结
一、Translation
本题链接:
题目: A. Translation time limit per test2 seconds me...
一、Translation
本题链接:
题目:
A. Translation
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc. However, it’s easy to make a mistake during the «translation». Vasya translated word s from Berlandish into Birlandish as t. Help him: find out if he translated the word correctly.
Input
The first line contains word s, the second line contains word t. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols.
Output
If the word t is a word s, written reversely, print YES, otherwise print NO.
Examples
input
code
edoc
output
YES
input
abb
aba
output
NO
input
code
code
output
NO
本博客给出本题截图:
题意:输入两个字符串,如果一个字符串reverse
一遍正好和另一个字符串一样的话,就输出YES
,否则输出NO
AC代码1
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a, b;
cin >> a >> b;
bool flag = false;
for (int i = 0, j = b.size() - 1; i < a.size(); i ++, j -- )
if (a[i] != b[j])
{
flag = true;
break;
}
if (flag) puts("NO");
else puts("YES");
return 0;
}
AC代码2
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string a, b;
cin >> a >> b;
reverse(a.begin(), a.end());
if (a == b) puts("YES");
else puts("NO");
return 0;
}
总结
水题,不解释
文章来源: chen-ac.blog.csdn.net,作者:辰chen,版权归原作者所有,如需转载,请联系作者。
原文链接:chen-ac.blog.csdn.net/article/details/117440563
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)