Last active
December 21, 2015 16:49
-
-
Save sarum9in/6336425 to your computer and use it in GitHub Desktop.
This file contains 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 <fstream> | |
#include <iostream> | |
#include <iterator> | |
using namespace std; | |
template <typename Iter> | |
inline void safe_advance(Iter &i, const Iter &end, std::size_t steps) | |
{ | |
while (steps-- > 0) | |
{ | |
if (i != end) | |
++i; | |
else | |
return; | |
} | |
} | |
int main() | |
{ | |
typedef istreambuf_iterator<char> char_input; | |
{ | |
static std::ifstream fin("1.txt"); | |
std::cin.rdbuf(fin.rdbuf()); | |
} | |
for (char_input j(cin), end; j != end; safe_advance(j, end, 2)) | |
cout << *j; | |
cout << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment