Base structure for development
This commit is contained in:
commit
b372144171
16
2022/base/Makefile
Normal file
16
2022/base/Makefile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
CXX ?= c++
|
||||||
|
CXXFLAGS ?= -std=c++11 -Wall -Wextra -pedantic -O2
|
||||||
|
PROJECT = PROJECT_NAME
|
||||||
|
|
||||||
|
all: ${PROJECT}
|
||||||
|
|
||||||
|
${PROJECT}: main.cpp
|
||||||
|
${CXX} ${CXXFLAGS} -o $@ $^
|
||||||
|
|
||||||
|
test: ${PROJECT}
|
||||||
|
./${PROJECT}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
${RM} *.o ${PROJECT}
|
||||||
|
|
||||||
|
.PHONY: all clean test
|
27
2022/base/main.cpp
Normal file
27
2022/base/main.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
std::vector<int> getInput( std::ifstream &file ) {
|
||||||
|
std::vector<int> ret{};
|
||||||
|
int tmp = 0;
|
||||||
|
std::string str;
|
||||||
|
while ( std::getline( file, str ) ) {
|
||||||
|
std::stringstream ss( str );
|
||||||
|
ss >> tmp;
|
||||||
|
ret.push_back( tmp );
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ifstream input_file( "input" );
|
||||||
|
auto input = getInput( input_file );
|
||||||
|
int part1 = input[0];
|
||||||
|
int part2 = input[0]+1;
|
||||||
|
std::cout << "Part 1 result is \033[91;1m" << part1
|
||||||
|
<< "\033[0m." << std::endl;
|
||||||
|
std::cout << "Part 2 result is \033[91;1m" << part2
|
||||||
|
<< "\033[0m." << std::endl;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user