Last active
September 17, 2015 00:14
-
-
Save zafe/554137ad81296a304fca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <algorithm> | |
#include <iterator> | |
#include <vector> | |
using namespace std; | |
int main(){ | |
int n, cnt = 0, i; | |
string s, answer, aux; | |
vector<char> vec; | |
cin >> n >> s; | |
for (i = 0; i < s.size() / n ; i++){ | |
if(i % 2 == 0) answer[cnt] = s[i*n]; | |
else{ | |
aux = s.substr(i*n, i*n + n - 1); | |
reverse(aux.begin() , aux.end()); | |
answer[cnt] = aux[i*n]; | |
} | |
cnt++; | |
} | |
cout << answer; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment