-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* compile via g++ -o proj1 project1.cpp */ | ||
#include <iostream> | ||
#include <string> | ||
using namespace std; | ||
|
||
/* singly linked list */ | ||
struct Node { | ||
string item; | ||
float cost; | ||
int qty; | ||
Node *next; | ||
}; | ||
|
||
int main(){ | ||
Node head; | ||
Node n; | ||
n.item = "TEST"; | ||
n.cost = 999.99; | ||
n.qty = 2; | ||
|
||
head.next = &n; | ||
|
||
Node currNode; | ||
Node nextNode; | ||
currNode = *head.next; | ||
currNode.next = &nextNode; | ||
|
||
cout << currNode.item << endl; | ||
|
||
cout << (head.next++)->item << endl; | ||
cout << (head.next->next++)->item << endl; | ||
return 0; | ||
} |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import time | ||
|
||
import random | ||
|
||
def gen_random_int(start = 1,limit=100000): | ||
nums = (random.randint(start,limit) for x in range(limit)) | ||
return nums | ||
|
||
|
||
def sum_nums(gen_nums): | ||
total = 0 | ||
for num in gen_nums: | ||
total += num | ||
|
||
return total | ||
|
||
|
||
|
||
def main(): | ||
curr_time = time.clock() | ||
nums = gen_random_int(1,1000000) | ||
total = sum_nums(nums) | ||
end_time = time.clock() | ||
print ("time taken: ", end_time - curr_time, " value was: ",total) | ||
|
||
|
||
|
||
main() |