Skip to content

Commit 6f4cec4

Browse files
committed
2021:01: Solve part 1 [cpp]
1 parent 0168094 commit 6f4cec4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

2021/day01/part1/solution.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <iostream>
2+
#include <fstream>
3+
4+
using namespace std;
5+
6+
int main() {
7+
ifstream infile ("../input");
8+
int inputNumbers[2000];
9+
10+
int curInNumber;
11+
int curInLineInx = -1;
12+
while (infile >> curInNumber) {
13+
curInLineInx += 1;
14+
inputNumbers[curInLineInx] = curInNumber;
15+
}
16+
17+
int wentDeeperTimes = 0;
18+
int prevNum = inputNumbers[0];
19+
for (int i = 1; i < 2000; i++) {
20+
int curNum = inputNumbers[i];
21+
if (curNum > prevNum) {
22+
wentDeeperTimes += 1;
23+
}
24+
prevNum = curNum;
25+
}
26+
27+
cout << wentDeeperTimes << endl;
28+
}

0 commit comments

Comments
 (0)