<\/span><\/h2>\n\n\n\nGiven a string, S<\/em><\/strong>, of length N<\/em><\/strong> that is indexed from 0<\/strong> to N <\/em>– 1<\/strong>, print its even-indexed<\/em> and odd-indexed<\/em> characters as 2<\/strong> space-separated strings on a single line (see the Sample<\/em> below for more detail).<\/p>\n\n\n\nNote:<\/strong> 0<\/strong> is considered to be an even<\/em> index.<\/p>\n\n\n\nExample<\/strong><\/p>\n\n\n\ns<\/em> = adbecf<\/strong><\/p>\n\n\n\nPrint abc def<\/code><\/p>\n\n\n\n<\/span>Input Format<\/strong><\/span><\/h2>\n\n\n\nThe first line contains an integer, T<\/em><\/strong> (the number of test cases).
Each line i<\/em><\/strong> of the T<\/em><\/strong> subsequent lines contain a string, S<\/em><\/strong>.<\/p>\n\n\n\n<\/span>Constraints<\/strong><\/span><\/h2>\n\n\n\nFor each String Sj<\/sub><\/em><\/strong> (where 0 <\/em><= j <\/em><= T – <\/em>1<\/strong>), print Sj<\/sub><\/em><\/strong>‘s even-indexed<\/em> characters, followed by a space, followed by Sj<\/sub><\/em><\/strong>‘s odd-indexed<\/em> characters.<\/p>\n\n\n\nSample Input<\/strong><\/p>\n\n\n\n2\nHacker\nRank<\/code><\/pre>\n\n\n\nSample Output<\/strong><\/p>\n\n\n\nHce akr\nRn ak<\/code><\/pre>\n\n\n\nExplanation<\/strong><\/p>\n\n\n\nTest Case 0<\/em>: S<\/em> = “Hacker”<\/strong>
S<\/em>[0] = “H”<\/strong>
S<\/em>[1] = “a”<\/strong>
S<\/em>[2] = “c”<\/strong>
S<\/em>[3] = “k”<\/strong>
S<\/em>[4] = “e”<\/strong>
S<\/em>[5] = “r”<\/strong>
The even<\/em> indices are 0<\/strong>, 2<\/strong>, and 4<\/strong>, and the odd<\/em> indices are 1<\/strong>, 3<\/strong>, and 5<\/strong>. We then print a single line<\/em> of 2<\/strong> space-separated strings; the first string contains the ordered characters from S<\/em><\/strong>‘s even<\/em> indices (Hce<\/strong>), and the second string contains the ordered characters from S<\/em><\/strong>‘s odd<\/em> indices (akr<\/strong>).<\/p>\n\n\n\nTest Case 1<\/em>: S<\/em> = “Rank”<\/strong>
S<\/em>[0] = “R”<\/strong>
S<\/em>[1] = “a”<\/strong>
S<\/em>[2] = “n”<\/strong>
S<\/em>[3] = “k”<\/strong>
The even<\/em> indices are 0<\/strong>, 2<\/strong> and 4<\/strong>, and the odd<\/em> indices are 1, 3<\/strong> and 5<\/strong>. We then print a single line<\/em> of 2<\/strong> space-separated strings; the first string contains the ordered characters from S<\/em><\/strong>‘s even<\/em> indices (Rn<\/strong>), and the second string contains the ordered characters from S<\/em><\/strong>‘s odd<\/em> indices (ak<\/strong>).<\/p>\n\n\n\n<\/span>Solution – Day 6: Let’s Review<\/strong><\/span><\/h2>\n\n\n\n<\/span>C++<\/strong><\/span><\/h3>\n\n\n\n#include <cmath>\n#include <cstdio>\n#include <vector>\n#include <iostream>\n#include <algorithm>\nusing namespace std;\n\nint main() \n{\n \/* Enter your code here. Read input from STDIN. Print output to STDOUT *\/ \n\n int N;\n cin >> N;\n\n for (int i = 0; i < N; i++) \n {\n string str;\n cin >> str;\n\n for (int j = 0; j < str.length(); j++) \n {\n if (j % 2 == 0)\n {\n cout << str[j];\n }\n }\n\n cout << \" \";\n\n for (int j = 0; j < str.length(); j++) \n {\n if (j % 2 != 0)\n {\n cout << str[j];\n }\n }\n\n cout << endl;\n }\n\n return 0;\n}<\/pre>\n\n\n\n