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
struct Point { | |
int x; | |
int y; | |
char s; | |
bool blocks; | |
color_t color; | |
bool operator==(const Point& other) const { | |
return x == other.x && y == other.y; | |
} | |
bool operator!=(const Point& other) const { |
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
struct Point { | |
int x; | |
int y; | |
char s; | |
bool blocks; | |
color_t color; | |
bool operator==(const Point& other) const { | |
return x == other.x && y == other.y; | |
} |
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
//How it works: automaton()->prep_fields()->place_seeds()->four_five()->flood_fill()->automaton() -> done. | |
// v ^ | |
// count_neighbors() | |
//How its used: Cave myCave(160, 40); | |
// myCave.automaton(); | |
// | |
//The completed cave is then available as myCave.layout; | |
#include <array> | |
#include <vector> | |
#include <list> |
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
template <typename T> | |
void shellSort(vector<T>& arr) | |
{ | |
int N = arr.size(); | |
for (int gap = N/2; gap > 0; gap /= 2) | |
{ | |
for (int i = gap; i < N; i += 1) | |
{ | |
int temp = arr[i]; | |
int j; |
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> | |
using namespace std; | |
struct Student { | |
std::string name; | |
int age; | |
int grade_level; | |
double gpa; | |
}; |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
struct retVals { | |
double result; | |
char *str; | |
}; | |
struct retVals* baz(int foo, int bar) |
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> | |
using namespace std; | |
std::pair<double, string> baz(int foo, int bar) | |
{ | |
double ans = double(foo)/double(bar); | |
return std::make_pair(ans, "Just Because."); | |
} | |
int main() |
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
std::tuple<double, string, float, float> baz(int foo, int bar) | |
{ | |
double ans = double(foo)/double(bar); | |
return std::make_tuple(ans, "Just Because.", float(foo), float(bar)); | |
} | |
int main() | |
{ | |
auto [answer, reply, foo, bar] = baz(8, 3); | |
std::cout<<foo<<"/"<<bar<<" = "; |
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
private Node<K,V> getMin(Node<K,V> h) | |
{ | |
if (h.leftChild() == null) | |
return h; | |
return getMin(h.leftChild()); | |
} | |
private Node<K,V> deleteMin(Node<K,V> h) | |
{ | |
if (h.leftChild() == null) |
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
private Node<K,V> delete(Node<K,V> h, K key) | |
{ | |
if (h == null) | |
return null; | |
if (key.compareTo(h.key()) < 0) | |
h.setLeft(delete(h.leftChild(), key)); | |
else if (key.compareTo(h.key()) > 0) | |
h.setRight(delete(h.rightChild(), key)); | |
else { |
OlderNewer