Skip to content

Instantly share code, notes, and snippets.

@sarum9in
Last active December 21, 2015 16:49
Show Gist options
  • Save sarum9in/6336425 to your computer and use it in GitHub Desktop.
Save sarum9in/6336425 to your computer and use it in GitHub Desktop.
#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