Skip to content

Instantly share code, notes, and snippets.

View paranoiacblack's full-sized avatar

Chris Manghane paranoiacblack

View GitHub Profile
@paranoiacblack
paranoiacblack / ex1.cpp
Created April 19, 2013 05:17
Lab 2 Exercise Solutions
#include <iostream>
#include <stack>
using namespace std;
template<typename T>
class Queue {
private:
stack<T> push_stack;
stack<T> pop_stack;
@paranoiacblack
paranoiacblack / ex1.cpp
Created April 6, 2013 05:46
CS14 SI Lab 1 Solutions
/* Using a stack to test if a string is a palindrome */
#include <iostream>
#include <stack>
#include <string>
using namespace std;
bool is_palindrome(const string& palindrome_candidate) {
string reversed_candidate = "";
@paranoiacblack
paranoiacblack / intlist_main.cpp
Created March 15, 2013 07:40
CS12 SI Lab9 Exercise 1
// Try running this program multiple times without fixing anything to see what
// we mean by random places in memory. It's kind of more random than a random
// number generator.
#include <iostream>
#include "intlist.h"
#include <cmath>
#include <cstdlib>
using namespace std;
#include <iostream>
using namespace std;
struct Leaf {
Leaf* left;
Leaf* right;
int value;
Leaf(int value)
@paranoiacblack
paranoiacblack / course.cpp
Created February 8, 2013 06:45
CS12 SI Lab 5
#include "course.h"
Course::Course() {}
Course::Course(const string& courseID, const string& callNo,
const string& course_name, const string& course_type,
const string& days)
: courseID(courseID), callNo(callNo), course_name(course_name),
course_type(course_type), days(days) {
}
@paranoiacblack
paranoiacblack / Makefile
Created January 25, 2013 21:17
CS12 Lab Session 3 Solution
CXX=g++
CXXFLAGS=-g -W -Wall -Werror -pedantic -ansi
OBJS=person.o
MAIN=main.cpp
all: $(OBJS)
$(CXX) $(CXXFLAGS) $(MAIN) $(OBJS) -o mytwitface
person.o: person.h person.cpp
@paranoiacblack
paranoiacblack / main.cpp
Last active December 11, 2015 12:38
Lecture Session 3: What happens when you don't use inclusion guards?
#include "rectangle.h"
#include "point.h"
int main() {
Point p;
return 0;
}
@paranoiacblack
paranoiacblack / Makefile
Last active December 11, 2015 11:28
Class solutions to SI Lab Session 2 for CS12 Winter 2013
CXX=g++
CXXFLAGS=-g -W -Wall -Werror
OBJECTS=book.o library.o point.o rectangle.o
MAIN=main.cpp
all: $(OBJECTS)
$(CXX) $(CXXFLAGS) $(MAIN) $(OBJECTS)
rectangle.o: point.o
@paranoiacblack
paranoiacblack / annoying_validation.cpp
Created October 29, 2012 06:45
CS 10 SI Classroom Session 5 - Removing duplicated code into a function
#include <iostream>
using namespace std;
int main() {
string twoCharInput = "";
string fiveCharInput = "";
string tenCharInput = "";
// Make user continue entering word until it is the
@paranoiacblack
paranoiacblack / main.cpp
Created October 22, 2012 06:51
CS 10 SI Classroom Session 4 - Palindrome Testing
#include <iostream>
using namespace std;
int main() {
// In programming, a sentinel value is a special value that guarantees
// loop termination when seen. In this example, we use 'q' to represent quit.
const string SENTINEL = "q";
string userInput = "";