公式
A - Appender 解説 by en_translator
For beginners
- If you are new to learning programming and do not know where to start, please try Problem A "Welcome to AtCoder" from practice contest. There you can find a sample code for each language.
- Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in "AtCoder Beginners Selection".
- 「C++入門 AtCoder Programming Guide for beginners (APG4b)」 is a C++ tutorial for competitive programmers. Sadly, this is only in Japanese too.
- 「Python入門 AtCoder Programming Guide for beginners (APG4bPython)」 is a Python tutorial for competitive programmers. Again, this is only in Japanese.
Check if the last character of the given string coincides with e, append an appropriate string to \(S\), and print it.
Sample code (Python)
In Python, s[-1] yields the last character of s. This is applicable to other data structures, like a list.
s = input()
if s[-1] == 'e':
t = s + "r"
else:
t = s + "er"
print(t)
Sample code (C++)
In C++, s.back() yields the last character of s. This is applicable to other structures, like a vector.
#include <iostream>
using std::cin;
using std::cout;
#include <string>
using std::string;
int main (void) {
string s;
cin >> s;
string t;
if (s.back() == 'e') {
t = s + "r";
} else {
t = s + "er";
}
cout << t << "\n";
return 0;
}
投稿日時:
最終更新: