Fixed zero initializers
This commit is contained in:
parent
ab21e8ad7d
commit
df8bddb55a
4 changed files with 14 additions and 10 deletions
|
|
@ -9,7 +9,7 @@ int main()
|
|||
{
|
||||
std::vector<int> depths = readToInt("../input/01.txt");
|
||||
|
||||
int increases = 0;
|
||||
int increases{};
|
||||
for(auto i = 0; i < depths.size() - 1; i++)
|
||||
increases += 1 * (depths[i] < depths[i+1]);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ int main()
|
|||
{
|
||||
std::vector<int> depths = readToInt("../input/01.txt");
|
||||
|
||||
int increases = 0;
|
||||
int increases{};
|
||||
for(auto i = 0; i < depths.size() - 3; i++)
|
||||
increases += 1 * (depths[i]+depths[i+1]+depths[i+2] < depths[i+1]+depths[i+2]+depths[i+3]);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ const std::vector<std::string>& readToString(const std::string& path);
|
|||
int main()
|
||||
{
|
||||
std::vector<std::string> commands = readToString("../input/02.txt");
|
||||
long h,d = 0;
|
||||
long h{},d{};
|
||||
|
||||
for(auto& command : commands)
|
||||
for(std::string command : commands)
|
||||
{
|
||||
command.pop_back();
|
||||
int val = command.back() - 48;
|
||||
|
|
@ -23,7 +23,7 @@ int main()
|
|||
}
|
||||
}
|
||||
|
||||
std::cout << d*h << std::endl;
|
||||
std::cout << h*d << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -37,5 +37,7 @@ const std::vector<std::string>& readToString(const std::string& path)
|
|||
while(std::getline(inputFile, input))
|
||||
inputs.push_back(input);
|
||||
|
||||
inputFile.close();
|
||||
|
||||
return inputs;
|
||||
}
|
||||
|
|
@ -3,12 +3,12 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
const std::vector<std::string>& readToString(const std::string& path);
|
||||
std::vector<std::string> readToString(const std::string& path);
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<std::string> commands = readToString("../input/02.txt");
|
||||
long h,d,a = 0;
|
||||
long h{},d{},a{};
|
||||
|
||||
for(auto& command : commands)
|
||||
{
|
||||
|
|
@ -29,14 +29,16 @@ int main()
|
|||
return 0;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& readToString(const std::string& path)
|
||||
std::vector<std::string> readToString(const std::string& path)
|
||||
{
|
||||
std::ifstream inputFile(path);
|
||||
std::string input;
|
||||
static std::vector<std::string> inputs;
|
||||
std::vector<std::string> inputs;
|
||||
|
||||
while(std::getline(inputFile, input))
|
||||
inputs.push_back(input);
|
||||
|
||||
inputFile.close();
|
||||
|
||||
return inputs;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue