Official

A - Appender Editorial by en_translator Editorial for printing


For beginners

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;
}

posted:
last update: