Add .clang-format and apply it

This commit is contained in:
2021-12-02 07:18:16 +00:00
parent e58dede1b6
commit cd5e2538df
103 changed files with 2714 additions and 2132 deletions

View File

@@ -3,30 +3,31 @@
//
#include <cstdlib>
#include <iostream>
#include <limits>
#include <string>
#include <iostream>
#include <vector>
int main(void) {
std::vector<unsigned long> nums;
unsigned incrs{0};
std::string line;
while (std::getline(std::cin, line)) {
nums.push_back(std::stoul(line));
int main(void)
{
std::vector<unsigned long> nums;
unsigned incrs{0};
std::string line;
while (std::getline(std::cin, line)) {
nums.push_back(std::stoul(line));
}
assert(nums.size() >= 3);
unsigned long prev{std::numeric_limits<unsigned long>::max()};
for (std::size_t pos = 0; pos <= nums.size() - 3; ++pos) {
unsigned long current{0};
for (std::size_t i = pos + 0; i < pos + 3; ++i) {
current += nums[i];
}
assert(nums.size() >= 3);
unsigned long prev{std::numeric_limits<unsigned long>::max()};
for (std::size_t pos = 0; pos <= nums.size() - 3; ++pos) {
unsigned long current{0};
for (std::size_t i = pos + 0; i < pos + 3; ++i) {
current += nums[i];
}
if (current > prev) {
++incrs;
}
prev = current;
if (current > prev) {
++incrs;
}
std::cout << "Number of increments: " << incrs << '\n';
return EXIT_SUCCESS;
prev = current;
}
std::cout << "Number of increments: " << incrs << '\n';
return EXIT_SUCCESS;
}