Skip to content

Instantly share code, notes, and snippets.

@zafe
Last active September 17, 2015 00:14
Show Gist options
  • Save zafe/554137ad81296a304fca to your computer and use it in GitHub Desktop.
Save zafe/554137ad81296a304fca to your computer and use it in GitHub Desktop.
#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