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
class Add { | |
public static void main(String[] args) { | |
if (args.length != 2) { | |
System.err.println("Add can only add two numbers!"); | |
System.exit(1); | |
} | |
int a = 0; | |
int b = 0; | |
try { |
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
import java.util.Random; | |
import java.io.FileWriter; | |
import java.io.IOException; | |
class BenchmarkRandomNumberWriting { | |
public static void main(String[] args) { | |
if (args.length != 2) { | |
System.err.println("Incorrect number of arguments!"); | |
System.err.println( | |
"Usage: java BenchmarkRandomNumberGenerator <output file> <line count>"); |
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
#!/bin/bash | |
# the above line specifies the program used to run this script | |
# run like: ./acceptance_test.sh ascending 100 merge | |
# or: bash acceptance_test.sh ascending 100 merge | |
# bash is a very easy language to make mistakes in | |
# let's set a few flags that help catch errors | |
set -e # exit on error | |
set -u # make the use of non-existant variables an error | |
set -o pipefail # propogate errors through | pipelines |
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
# call this script like so: | |
# .\acceptance_test.ps1 -order random -size 1000 -algorithm merge | |
# call our program | |
java Assign1 $order $size $algorithm output.txt | |
# read our output file, convert each line to an integer, then sort, and output to an ascii text file | |
get-content output.txt | foreach-object { [Int] $_ } | sort-object | out-file -encoding ascii sorted.txt | |
# unfortunately, compare-object does not care about order, so it can't check the sort |
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
import java.util.NoSuchElementException; | |
public class ForwardList<T> { | |
public ForwardList() { | |
head = tail = null; | |
} | |
public void insertAtHead(T data) { | |
Node<T> n = new Node<T>(data, head); | |
head = n; |
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 <QCoreApplication> | |
#include <QTimer> | |
#include "param.h" | |
int main(int argc, char *argv[]) | |
{ | |
QCoreApplication a(argc, argv); |
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 <assert.h> | |
#include <ctype.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdio.h> | |
#define _stricmp strcasecmp | |
#define _strdup strdup | |
typedef enum ETwKeyModifier |
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 <string.h> | |
int main() { | |
char buffer[6]; | |
char* h = "hello"; | |
// copy the string from 'h' into 'buffer' | |
strcpy(buffer, h); | |
// now change the first letter in the buffer |
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> | |
void print_sizeof(char* ptr) { | |
printf("The passed variable is %u bytes large\n", (unsigned int)sizeof(ptr)); | |
} | |
int main() { | |
char arr[] = "Hello World!"; | |
char* ptr = "Hello World!"; |
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
gcc main.c -o hello | |
./hello |
OlderNewer