Skip to content

Instantly share code, notes, and snippets.

@rkt2spc
Created June 7, 2017 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkt2spc/f0d755263c5aa0a169a9ff8aba7a29cf to your computer and use it in GitHub Desktop.
Save rkt2spc/f0d755263c5aa0a169a9ff8aba7a29cf to your computer and use it in GitHub Desktop.
test
#include <iostream>
#include <fstream>
using namespace std;
/* CONSTANTS */
#define MAX_SIZE 65536;
struct Location {
int row, col;
};
struct Input {
int start_row, start_col;
int gas_capacity;
int size_row, size_col;
int grid[1000][1000];
};
Input readInput(string file_path) {
cout << "Reading input from " << file_path << endl;
Input input;
ifstream finput(file_path, ios::in);
finput >> input.start_row >> input.start_col;
finput >> input.gas_capacity;
finput >> input.size_row >> input.size_col;
for (int i = 0; i < input.size_row; ++i) {
for (int j = 0; j < input.size_col; ++j) {
finput >> input.grid[i][j];
}
}
return input;
}
int showInput(Input input) {
cout << "Hello" << endl;
return 1;
// cout << input.start_row << " " << input.start_col << endl;
// cout << input.gas_capacity << endl;
// cout << input.size_row << " " << input.size_col << endl;
// for (int i = 0; i < input.size_row; ++i) {
// for (int j = 0; j < input.size_col; ++j) {
// cout << input.grid[i][j];
// }
// cout << endl;
// }
}
int main(int argc, const char * argv[]) {
if (argc < 2) {
cout << "Missing argument: input file";
return 1;
}
Input input = readInput(argv[1]);
cout << input.start_row << " " << input.start_col << endl;
cout << input.gas_capacity << endl;
cout << input.size_row << " " << input.size_col << endl;
for (int i = 0; i < input.size_row; ++i) {
for (int j = 0; j < input.size_col; ++j) {
cout << input.grid[i][j];
}
cout << endl;
}
int x = showInput(input);
cout << "Work well" << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment