समस्या
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 के लिए अनुकूलित की गई है। ऊपर दिए गए स्टेटमेंट और सीमाओं का पालन करें।