Pujan Day 1 Advent
This commit is contained in:
parent
a92879c27b
commit
023b85247e
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -0,0 +1,43 @@
|
|||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <vector>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string filename("data.txt");
|
||||
std::ifstream input{filename};
|
||||
|
||||
int prev = 0;
|
||||
int current = 0;
|
||||
int counter = 0;
|
||||
|
||||
if(!input.is_open())
|
||||
{
|
||||
std::cerr << "Couldn't read file: " << filename << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (std::string line; std::getline(input, line);)
|
||||
{
|
||||
if (prev == 0)
|
||||
{
|
||||
prev = std::stoi(line);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
current = std::stoi(line);
|
||||
|
||||
if (prev < current)
|
||||
{
|
||||
counter ++;
|
||||
}
|
||||
|
||||
prev = current;
|
||||
}
|
||||
}
|
||||
std::cout << counter << std::endl;
|
||||
|
||||
}
|
Loading…
Reference in New Issue