#include <iostream>
#include <string>
using namespace std;
int main() {
int t;
cin >> t >> t;
string s;
getline(cin, s);
getline(cin, s);
if (t&1)
for (int i=s.length()-1; i>=0; i-=2)
cout << s[i] << " ";
else
for (int i=0; i<=s.length()-1; i+=2)
cout << s[i] << " ";
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <iostream> #include <string> using namespace std; int main() { int t; cin >> t >> t; string s; getline(cin, s); getline(cin, s); if (t&1) for (int i=s.length()-1; i>=0; i-=2) cout << s[i] << " "; else for (int i=0; i<=s.length()-1; i+=2) cout << s[i] << " "; return 0; } |
English