問題
翻訳を表示Build a new string from the characters of text at positions 0, 2, 4, … (every other character, starting with the first).
Implement every_other_character(text).
Input
text: The original text.
Output
Return the characters at even positions, in order.
制約
0 ≤ length of text ≤ 10,000
例
例 1
入力:
text = "programming"
期待される出力:
expected = "pormig"
入力:
std::string text = "programming";
期待される出力:
std::string expected = "pormig";
入力:
string text = "programming";
期待される出力:
string expected = "pormig";
解説
Positions 0, 2, 4, 6, 8, 10 give p, o, r, m, i, g: "pormig".
例 2
入力:
text = "a"
期待される出力:
expected = "a"
入力:
std::string text = "a";
期待される出力:
std::string expected = "a";
入力:
string text = "a";
期待される出力:
string expected = "a";
解説
Only position 0 exists: "a".
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。