Last active
August 8, 2020 10:18
-
-
Save pce/067f37ac6ced9ddec1e538f8c6da56f9 to your computer and use it in GitHub Desktop.
To compile and play with the sum of odds in C++: `g++ aoc_01-sumofofodd.cpp && ./a.out` or `clang++ -std=c++11 -stdlib=libc++ -g aoc_01-sumofofodd.cpp && ./a.out`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <math.h> | |
using std::cout; | |
using std::string; | |
using std::vector; | |
vector<int> SumOfOdd(int n) { | |
vector<int> v; | |
double sumOfOdd = .0; | |
for (int i=0; i<=n; i++) { | |
sumOfOdd = pow(1.0 + (double)i, 2.0); | |
v.push_back((int)sumOfOdd); | |
} | |
return v; | |
} | |
void PrintBoard(const vector<int> board) { | |
for (int i = 0; i < board.size(); i++) { | |
cout << board[i]; | |
cout << "\n"; | |
} | |
cout << "\n"; | |
} | |
int main() { | |
auto board = SumOfOdd(8); | |
PrintBoard(board); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment