Last active
August 29, 2015 14:14
-
-
Save becxer/67b3770e9c1809d3a5bc to your computer and use it in GitHub Desktop.
algorithm solving template for cpp
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> | |
#define VERSION "ARGV" //FILE, STDIN, ARGV | |
using namespace std; | |
char* INPUT_TEXT = "test.in"; | |
char* OUTPUT_TEXT = "test.out"; | |
int solution(istream& in, ostream& out){ | |
return 0; | |
} | |
int main(int argc, char* argv[]){ | |
istream* in = &cin; ostream* out = &cout; | |
ifstream ifs; ofstream ofs; | |
if (VERSION == "ARGV"){ | |
if(argc != 2) { | |
cout << "a.out input.txt" << endl; | |
return 0; | |
} | |
INPUT_TEXT = argv[1]; | |
ifs.open(INPUT_TEXT); | |
in = &ifs; | |
} | |
if (VERSION == "FILE"){ | |
ifs.open(INPUT_TEXT); | |
ofs.open(OUTPUT_TEXT); | |
in = &ifs; out = &ofs; | |
} | |
return solution(*in,*out); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment