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> | |
using namespace std; | |
void recursive(string s, int count, int limit) | |
{ | |
if (count < limit) | |
{ | |
for (int i = 0; i < count; i++) | |
{ |
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; | |
int main() | |
{ | |
int num; | |
cout << "The address of 'num': " << &num << endl; |
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
/* Some examples of functions handling arrays and pointers | |
* Created by Amin Mesbah | |
* | |
* This is free and unencumbered software released into the public domain. | |
* | |
* Anyone is free to copy, modify, publish, use, compile, sell, or | |
* distribute this software, either in source code form or as a compiled | |
* binary, for any purpose, commercial or non-commercial, and by any | |
* means. | |
* |
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
from pprint import pprint | |
# Create an empty dictionary: | |
log_entry = {} | |
# Add a key called 'ipaddr' to the dict, and assign | |
# a value to it: | |
log_entry['ipaddr'] = '192.168.1.1' | |
# Add more keys and corresponding values: |
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
{ | |
"key":1234, | |
"key":5678, | |
"key":"abcd", | |
"bork":"asdf", | |
"bork":"dfsd" | |
} |
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; | |
// These are the function prototypes | |
int addTenByValue(int num); | |
int addTenByReference(int &num); | |
void addTenNoReturn(int &num); | |
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
# This is a simplified version of a more complex problem I'm trying to solve. | |
# search() seems to have the desired behavior (see docstring), but seems a bit clumsy. | |
# Is there a more pythonic way to do this? | |
def search(my_list, my_dict, search_term): | |
"""Example Output: | |
--- | |
>>> l = [1, 2, 3, 4] | |
>>> d = {1: "foo", 2: "bar", 3: "baz", 4: "baz"} | |
>>> search(l, d, "borkborkbork") |
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
// When this program is executed multiple times, the first number generated is always the same. | |
// The other numbers in the 5 number sequence are random. | |
// I'm confused about why the first number isn't random | |
#include <iostream> | |
#include <random> | |
#include <time.h> | |
using namespace std; |