diff options
author | zedarider <ymherklotz@gmail.com> | 2016-02-26 21:15:09 +0000 |
---|---|---|
committer | zedarider <ymherklotz@gmail.com> | 2016-02-26 21:15:09 +0000 |
commit | f7a1296d353dea1f98b47d4baef87426ceadf6b5 (patch) | |
tree | c4fc565b3e2f672647033d639601f695782f1562 | |
parent | c2d76b36f9f2ef70de599add53c08a38af3d1760 (diff) | |
download | imperial_2015-f7a1296d353dea1f98b47d4baef87426ceadf6b5.tar.gz imperial_2015-f7a1296d353dea1f98b47d4baef87426ceadf6b5.zip |
Organising into folders
-rw-r--r-- | C++/Append.cpp | 29 | ||||
-rw-r--r-- | C++/BinarySearch.cpp | 23 | ||||
-rw-r--r-- | C++/Collatz.cpp | 34 | ||||
-rw-r--r-- | C++/DictRealEstate.txt | 6 | ||||
-rw-r--r-- | C++/DynamicArray.cpp | 78 | ||||
-rw-r--r-- | C++/Euclid.cpp | 19 | ||||
-rw-r--r-- | C++/EvenOddCom1ex.cpp | 18 | ||||
-rw-r--r-- | C++/Factorisation.cpp | 55 | ||||
-rw-r--r-- | C++/FirstFile.txt | 5 | ||||
-rw-r--r-- | C++/Firstname.txt | 5 | ||||
-rw-r--r-- | C++/HelloWorld.cpp | 18 | ||||
-rw-r--r-- | C++/LinkedLists.cpp | 41 | ||||
-rw-r--r-- | C++/MinMax.cpp | 42 | ||||
-rw-r--r-- | C++/NamesandSurnames.cpp | 39 | ||||
-rw-r--r-- | C++/PointFile.txt | 54 | ||||
-rw-r--r-- | C++/Preferences1.txt | 406 | ||||
-rw-r--r-- | C++/Preferences2.txt | 35 | ||||
-rw-r--r-- | C++/RawMemory.cpp | 14 | ||||
-rw-r--r-- | C++/RealEstate.cpp | 60 | ||||
-rw-r--r-- | C++/Recursion.cpp | 41 | ||||
-rw-r--r-- | C++/SecondFile.txt | 5 | ||||
-rw-r--r-- | C++/Sets.cpp | 63 | ||||
-rw-r--r-- | C++/SumAndScalar.cpp | 47 | ||||
-rw-r--r-- | C++/Surname.txt | 5 | ||||
-rw-r--r-- | C++/Test1.cpp | 94 | ||||
-rw-r--r-- | C++/TestExample2.cpp | 55 | ||||
-rw-r--r-- | C++/TriangularDivisor.cpp | 29 | ||||
-rw-r--r-- | C++/Warehouse1.txt | 5 | ||||
-rw-r--r-- | C++/Warehouse2.txt | 3 | ||||
-rw-r--r-- | C++/smalltest.cpp | 16 | ||||
-rw-r--r-- | C++/w4.cpp | 24 |
31 files changed, 1368 insertions, 0 deletions
diff --git a/C++/Append.cpp b/C++/Append.cpp new file mode 100644 index 0000000..5b88e6c --- /dev/null +++ b/C++/Append.cpp @@ -0,0 +1,29 @@ +#include <iostream> +#include <cmath> +#include <vector> + +using namespace std; + +vector<int> append(vector<int> v1, vector<int> v2) { + for(int i = 0; i < v2.size(); i++) { + v1.push_back(v2[i]); + } + return v1; +} + +int main() { + vector<int> a, b, c; + a.push_back(1); + a.push_back(2); + a.push_back(3); + b.push_back(4); + b.push_back(5); + b.push_back(6); + c = append(a, b); + cout << "c: "; + for(int k = 0; k < c.size(); k++) { + cout << c[k] << " "; + } + cout << endl; + return 0; +}
\ No newline at end of file diff --git a/C++/BinarySearch.cpp b/C++/BinarySearch.cpp new file mode 100644 index 0000000..a9e73b6 --- /dev/null +++ b/C++/BinarySearch.cpp @@ -0,0 +1,23 @@ +#include <iostream> + +using namespace std; + +int main() { + double result, num, divi; + result = 0.0; + num = 1.0; + divi = 1.0; + + for(int i = 2; i < 1000; i++) { + for(int j = 2; j < 1000; j++) { + num = (double)i; + divi = (double)j; + result = (double)(num/divi)*((num-1)/(divi-1)); + if(result == 0.5) { + cout << i << " " << j << endl; + } + cout << j << endl; + } + } + return 0; +}
\ No newline at end of file diff --git a/C++/Collatz.cpp b/C++/Collatz.cpp new file mode 100644 index 0000000..5263710 --- /dev/null +++ b/C++/Collatz.cpp @@ -0,0 +1,34 @@ +#include <iostream> +#include <cmath> + +using namespace std; + +int main() { + int usrNum, usrNum1, usrNum2; + int count; + + cout << "Please Enter a range: "; + cin >> usrNum1 >> usrNum2; + + cout << "\nnumber\tsteps\n"; +// cout << usrNum1 << "\t" << usrNum2 << endl; + for(usrNum=usrNum1; usrNum<=usrNum2; usrNum++) { + count = 0; + int initNum = usrNum; + while(initNum > 1) { + if(initNum % 2 == 0) { + initNum = initNum / 2; + } + else { + initNum = initNum*3 + 1; + } + + count ++; + } + cout << usrNum << "\t" << count << "\t"; + for(int x = 0; x < count; x++) { + cout << "*"; + } + cout << endl; + } +}
\ No newline at end of file diff --git a/C++/DictRealEstate.txt b/C++/DictRealEstate.txt new file mode 100644 index 0000000..5858691 --- /dev/null +++ b/C++/DictRealEstate.txt @@ -0,0 +1,6 @@ +exclusive expensive +cosy small +bedsit room +quiet remote +luxurious expensive +lovely tiny
\ No newline at end of file diff --git a/C++/DynamicArray.cpp b/C++/DynamicArray.cpp new file mode 100644 index 0000000..4875109 --- /dev/null +++ b/C++/DynamicArray.cpp @@ -0,0 +1,78 @@ +#include <iostream> +#include <fstream> +#include <cstdlib> +#include <string> + +using namespace std; + +// point object structure +struct point { + double x, y; + + void p_str() { + cout << "(" << x << ", " << y << ")" << endl; + } +}; + +// declaration of method +void readPoints(string, int&, int&, point*&); + +int main() { + string fileLocation = "./PointFile.txt"; + // declares the size and capacity of the array which both have to be tracked and initialises them + int size = 0; + int capacity = 1; + point* pArray = new point[capacity]; + readPoints(fileLocation, capacity, size, pArray); + + // prints out the content of the array + for(int i = 0; i < size; i++) { + pArray[i].p_str(); + } + + // prints out the characteristics of the array + cout << "array capacity:\t\t" << capacity << endl << "array size:\t\t" << size << endl << "array physical size:\t" << size*sizeof(point) << " bits\t=\t" << size*sizeof(point)/8 << " bytes" << endl; + + delete[] pArray; + return 0; +} + +// method that creates the array +void readPoints(string fileloc, int &cpcty, int &sz, point* &pa) { + // declares file and other variables + ifstream pointFile; + point tmpp; + + pointFile.open(fileloc); + + // Error opening file + if(!pointFile.is_open()) { + cout << "couldn't open input file" << endl; + exit(EXIT_FAILURE); + } + + // reads the two points from the file + while(pointFile >> tmpp.x >> tmpp.y) { + // increases the sz of the array + sz++; + // checks if the array is still large enough for the element + if(sz <= cpcty) { + // adds point to the end of the array + pa[sz-1] = tmpp; + } else { + // if array isn't large enough creates new dynamic array + // of two times the sz + point* tmpa = new point[cpcty*=2]; + for(int i = 0; i < sz; i++) { + tmpa[i] = pa[i]; + } + // never have to delete the tmpa as it points to the new pa + tmpa[sz-1] = tmpp; + // delete old pa + delete[] pa; + pa = tmpa; + } + } + + pointFile.close(); +}
\ No newline at end of file diff --git a/C++/Euclid.cpp b/C++/Euclid.cpp new file mode 100644 index 0000000..b2daaaa --- /dev/null +++ b/C++/Euclid.cpp @@ -0,0 +1,19 @@ +#include <iostream> +#include <cmath> + +using namespace std; + +int mgcd(int a, int b) { + if(a % b != 0) { + mgcd(b, a % b); + } else { + cout << "\nGreatest common divisor: " << b << endl; + } +} + +int main() { + int x, y; + cout << "Enter 2 numbers: "; + cin >> x >> y; + mgcd(x, y); +} diff --git a/C++/EvenOddCom1ex.cpp b/C++/EvenOddCom1ex.cpp new file mode 100644 index 0000000..aa3410e --- /dev/null +++ b/C++/EvenOddCom1ex.cpp @@ -0,0 +1,18 @@ +#include <iostream> +#include <cmath> + +using namespace std; + +int main() { + int num; + cout << "Please enter a number: "; + cin >> num; + if(num % 2 == 0) { + cout << "even" << endl; + } + else { + cout << "odd" << endl; + } + + return 0; +}
\ No newline at end of file diff --git a/C++/Factorisation.cpp b/C++/Factorisation.cpp new file mode 100644 index 0000000..034a975 --- /dev/null +++ b/C++/Factorisation.cpp @@ -0,0 +1,55 @@ +#include <iostream> +#include <cmath> +#include <vector> + +using namespace std; + +void is_prime(int); +void print_vector(vector<int>); + +void is_prime(int x) { + int original = x; + vector<int> primes, factors; + primes.push_back(2); + primes.push_back(3); + + for(int i = 5; i <= x; i++) { + bool itsPrime = false; + for(int j = 0; j < primes.size(); j++) { + if(i % primes[j] == 0) { + itsPrime = false; + break; + } else { + itsPrime = true; + } + } + if(itsPrime) { + primes.push_back(i); + } + } + // cout << "Prime numbers to consider: "; + // print_vector(primes); + while(x != 1) { + for(int l = 0; l < primes.size(); l++) { + if(x % primes[l] == 0) { + factors.push_back(primes[l]); + x = x / primes[l]; + break; + } + } + } + cout << "Factors of " << original << ": "; + print_vector(factors); +} + +void print_vector(vector<int> v) { + for(int k = 0; k < v.size(); k++) { + cout << v[k] << " "; + } + cout << endl; +} + +int main() { + is_prime(103); + return 0; +}
\ No newline at end of file diff --git a/C++/FirstFile.txt b/C++/FirstFile.txt new file mode 100644 index 0000000..afd10c4 --- /dev/null +++ b/C++/FirstFile.txt @@ -0,0 +1,5 @@ +Donald Trump +Martin Wiersema +Alex Blanc +Yann Herklotz +Sam Wiggins diff --git a/C++/Firstname.txt b/C++/Firstname.txt new file mode 100644 index 0000000..26e8146 --- /dev/null +++ b/C++/Firstname.txt @@ -0,0 +1,5 @@ +Donald +Martin +Alex +Yann +Sam
\ No newline at end of file diff --git a/C++/HelloWorld.cpp b/C++/HelloWorld.cpp new file mode 100644 index 0000000..aa3410e --- /dev/null +++ b/C++/HelloWorld.cpp @@ -0,0 +1,18 @@ +#include <iostream> +#include <cmath> + +using namespace std; + +int main() { + int num; + cout << "Please enter a number: "; + cin >> num; + if(num % 2 == 0) { + cout << "even" << endl; + } + else { + cout << "odd" << endl; + } + + return 0; +}
\ No newline at end of file diff --git a/C++/LinkedLists.cpp b/C++/LinkedLists.cpp new file mode 100644 index 0000000..55dc090 --- /dev/null +++ b/C++/LinkedLists.cpp @@ -0,0 +1,41 @@ +#include <iostream> + +using namespace std; + +struct intList { + int val; + intList* next_el; +}; + +// add functions to add elements to a list +// create a list and be able to order them +// make ordered linked list + +int main() { + intList* ilist = NULL; + int el, n; + + cout << "How many elements do you want to add to the list?" << endl; + cin >> n; + cout << "Now please enter the " << n << " integers: " << endl; + for(int i = 0; i < n; ++i) { + cin >> el; + intList* tmp = new intList; + tmp->val = el; + tmp->next_el = ilist; + ilist = tmp; + } + cout << endl; + intList* lit = ilist; + while(lit != NULL) { + cout << lit->val << endl; + lit = lit->next_el; + } + + while(ilist != NULL) { + intList* tmpilist = ilist->next_el; + delete ilist; + ilist = tmpilist; + } + return 0; +} diff --git a/C++/MinMax.cpp b/C++/MinMax.cpp new file mode 100644 index 0000000..070c33f --- /dev/null +++ b/C++/MinMax.cpp @@ -0,0 +1,42 @@ +#include <iostream> +#include <vector> +#include <string> +#include <sstream> + +using namespace std; + +int main() { + double input, maxtmp, maxloc, mintmp, minloc, + addtmp, average; + vector<double> vin; + + cout << "Enter Number <q to exit>: "; + cin >> input; + + do { + cout << "Enter Number <q to exit>: "; + vin.push_back(input); + } while(cin >> input); + + mintmp = vin[0]; + maxtmp = vin[0]; + addtmp = 0; + + // cout << "values: " << mintmp << ", " << maxtmp << endl; + + for(int i = 0; i < vin.size(); i++) { + if(maxtmp <= vin[i]) { + maxtmp = vin[i]; + maxloc = i; + } else if (mintmp >= vin[i]) { + mintmp = vin[i]; + minloc = i; + } + addtmp += vin[i]; + } + average = addtmp / vin.size(); + cout << "\nmin: " << mintmp << " at pos: " << minloc << "\nmax: " + << maxtmp << " at pos: " << maxloc << "\naverage: " << + average << endl; + return 0; +} diff --git a/C++/NamesandSurnames.cpp b/C++/NamesandSurnames.cpp new file mode 100644 index 0000000..8d10b39 --- /dev/null +++ b/C++/NamesandSurnames.cpp @@ -0,0 +1,39 @@ +#include <iostream> +#include <cstdlib> +#include <string> +#include <fstream> +#include <sstream> +#include <vector> + +using namespace std; + +struct name { + string first_name, last_name; + + string _str() { + stringstream ss; + ss << last_name << ", " << first_name << endl; + return ss.str(); + } +}; + +int main() { + name student_name; + ifstream firstname, surname; + ofstream firstFile, secondFile; + + firstname.open("Firstname.txt"); + surname.open("Surname.txt"); + firstFile.open("FirstFile.txt"); + secondFile.open("SecondFile.txt"); + + while(firstname >> student_name.first_name) { + surname >> student_name.last_name; + firstFile << student_name.first_name << " " << student_name.last_name << endl; + secondFile << student_name._str(); + } + return 0; +} + + + diff --git a/C++/PointFile.txt b/C++/PointFile.txt new file mode 100644 index 0000000..74705a9 --- /dev/null +++ b/C++/PointFile.txt @@ -0,0 +1,54 @@ +2 3 +4 2 +1 9 +49 29 +382 93 +1 23 +2 3 +4 2 +1 9 +49 29 +382 93 +1 23 +2 3 +4 2 +1 9 +49 29 +382 93 +1 23 +2 3 +4 2 +1 9 +49 29 +382 93 +1 23 +2 3 +4 2 +1 9 +49 29 +382 93 +1 23 +2 3 +4 2 +1 9 +49 29 +382 93 +1 23 +2 3 +4 2 +1 9 +49 29 +382 93 +1 23 +2 3 +4 2 +1 9 +49 29 +382 93 +1 23 +2 3 +4 2 +1 9 +49 29 +382 93 +1 23
\ No newline at end of file diff --git a/C++/Preferences1.txt b/C++/Preferences1.txt new file mode 100644 index 0000000..ca1c4d2 --- /dev/null +++ b/C++/Preferences1.txt @@ -0,0 +1,406 @@ +// Place your settings in the file "User/Preferences.sublime-settings", which +// overrides the settings in here. +// +// Settings may also be placed in file type specific options files, for +// example, in Packages/Python/Python.sublime-settings for python files. +{ + // Sets the colors used within the text area + "color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", + + // Note that the font_face and font_size are overridden in the platform + // specific settings file, for example, "Preferences (Linux).sublime-settings". + // Because of this, setting them here will have no effect: you must set them + // in your User File Preferences. + "font_face": "", + "font_size": 10, + + // Valid options are "no_bold", "no_italic", "no_antialias", "gray_antialias", + // "subpixel_antialias", "no_round" (OS X only), "gdi" (Windows only) and + // "directwrite" (Windows only) + "font_options": [], + + // Characters that are considered to separate words + "word_separators": "./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}`~?", + + // Set to false to prevent line numbers being drawn in the gutter + "line_numbers": true, + + // Set to false to hide the gutter altogether + "gutter": true, + + // Spacing between the gutter and the text + "margin": 4, + + // Fold buttons are the triangles shown in the gutter to fold regions of text + "fold_buttons": true, + + // Hides the fold buttons unless the mouse is over the gutter + "fade_fold_buttons": true, + + // Columns in which to display vertical rulers + "rulers": [], + + // Set to true to turn spell checking on by default + "spell_check": false, + + // The number of spaces a tab is considered equal to + "tab_size": 4, + + // Set to true to insert spaces when tab is pressed + "translate_tabs_to_spaces": false, + + // If translate_tabs_to_spaces is true, use_tab_stops will make tab and + // backspace insert/delete up to the next tabstop + "use_tab_stops": true, + + // Set to false to disable detection of tabs vs. spaces on load + "detect_indentation": true, + + // Calculates indentation automatically when pressing enter + "auto_indent": true, + + // Makes auto indent a little smarter, e.g., by indenting the next line + // after an if statement in C. Requires auto_indent to be enabled. + "smart_indent": true, + + // Adds whitespace up to the first open bracket when indenting. Requires + // auto_indent to be enabled. + "indent_to_bracket": false, + + // Trims white space added by auto_indent when moving the caret off the + // line. + "trim_automatic_white_space": true, + + // Disables horizontal scrolling if enabled. + // May be set to true, false, or "auto", where it will be disabled for + // source code, and otherwise enabled. + "word_wrap": "auto", + + // Set to a value other than 0 to force wrapping at that column rather than the + // window width + "wrap_width": 0, + + // Set to false to prevent word wrapped lines from being indented to the same + // level + "indent_subsequent_lines": true, + + // Draws text centered in the window rather than left aligned + "draw_centered": false, + + // Controls auto pairing of quotes, brackets etc + "auto_match_enabled": true, + + // Word list to use for spell checking + "dictionary": "Packages/Language - English/en_US.dic", + + // Sets which scopes are checked for spelling errors + "spelling_selector": "markup.raw, source string.quoted - punctuation - meta.preprocessor.c.include, source comment - source comment.block.preprocessor, -(source, constant, keyword, storage, support, variable, markup.underline.link, meta.tag)", + + // Set to true to draw a border around the visible rectangle on the minimap. + // The color of the border will be determined by the "minimapBorder" key in + // the color scheme + "draw_minimap_border": false, + + // Always visualise the viewport on the minimap, as opposed to only + // showing it on mouse over + "always_show_minimap_viewport": false, + + // If enabled, will highlight any line with a caret + "highlight_line": false, + + // Valid values are "smooth", "phase", "blink" and "solid". + "caret_style": "smooth", + + // These settings control the size of the caret + "caret_extra_top": 0, + "caret_extra_bottom": 0, + "caret_extra_width": 0, + + // Set to false to disable underlining the brackets surrounding the caret + "match_brackets": true, + + // Set to false if you'd rather only highlight the brackets when the caret is + // next to one + "match_brackets_content": true, + + // Set to false to not highlight square brackets. This only takes effect if + // match_brackets is true + "match_brackets_square": true, + + // Set to false to not highlight curly brackets. This only takes effect if + // match_brackets is true + "match_brackets_braces": true, + + // Set to false to not highlight angle brackets. This only takes effect if + // match_brackets is true + "match_brackets_angle": false, + + // Enable visualization of the matching tag in HTML and XML + "match_tags": true, + + // Highlights other occurrences of the currently selected text + "match_selection": true, + + // Additional spacing at the top of each line, in pixels + "line_padding_top": 0, + + // Additional spacing at the bottom of each line, in pixels + "line_padding_bottom": 0, + + // Set to false to disable scrolling past the end of the buffer. + // On OS X, this value is overridden in the platform specific settings, so + // you'll need to place this line in your user settings to override it. + "scroll_past_end": true, + + // This controls what happens when pressing up or down when on the first + // or last line. + // On OS X, this value is overridden in the platform specific settings, so + // you'll need to place this line in your user settings to override it. + "move_to_limit_on_up_down": false, + + // Set to "none" to turn off drawing white space, "selection" to draw only the + // white space within the selection, and "all" to draw all white space + "draw_white_space": "selection", + + // Set to false to turn off the indentation guides. + // The color and width of the indent guides may be customized by editing + // the corresponding .tmTheme file, and specifying the colors "guide", + // "activeGuide" and "stackGuide" + "draw_indent_guides": true, + + // Controls how the indent guides are drawn, valid options are + // "draw_normal" and "draw_active". draw_active will draw the indent + // guides containing the caret in a different color. + "indent_guide_options": ["draw_normal"], + + // Set to true to removing trailing white space on save + "trim_trailing_white_space_on_save": false, + + // Set to true to ensure the last line of the file ends in a newline + // character when saving + "ensure_newline_at_eof_on_save": false, + + // Set to true to automatically save files when switching to a different file + // or application + "save_on_focus_lost": false, + + // Save via writing to an alternate file, and then renaming it over the + // original file. + "atomic_save": false, + + // The encoding to use when the encoding can't be determined automatically. + // ASCII, UTF-8 and UTF-16 encodings will be automatically detected. + "fallback_encoding": "Western (Windows 1252)", + + // Encoding used when saving new files, and files opened with an undefined + // encoding (e.g., plain ascii files). If a file is opened with a specific + // encoding (either detected or given explicitly), this setting will be + // ignored, and the file will be saved with the encoding it was opened + // with. + "default_encoding": "UTF-8", + + // Files containing null bytes are opened as hexadecimal by default + "enable_hexadecimal_encoding": true, + + // Determines what character(s) are used to terminate each line in new files. + // Valid values are 'system' (whatever the OS uses), 'windows' (CRLF) and + // 'unix' (LF only). + "default_line_ending": "system", + + // When enabled, pressing tab will insert the best matching completion. + // When disabled, tab will only trigger snippets or insert a tab. + // Shift+tab can be used to insert an explicit tab when tab_completion is + // enabled. + "tab_completion": true, + + // Enable auto complete to be triggered automatically when typing. + "auto_complete": true, + + // The maximum file size where auto complete will be automatically triggered. + "auto_complete_size_limit": 4194304, + + // The delay, in ms, before the auto complete window is shown after typing + "auto_complete_delay": 50, + + // Controls what scopes auto complete will be triggered in + "auto_complete_selector": "source - comment, meta.tag - punctuation.definition.tag.begin", + + // Additional situations to trigger auto complete + "auto_complete_triggers": [ {"selector": "text.html", "characters": "<"} ], + + // By default, auto complete will commit the current completion on enter. + // This setting can be used to make it complete on tab instead. + // Completing on tab is generally a superior option, as it removes + // ambiguity between committing the completion and inserting a newline. + "auto_complete_commit_on_tab": false, + + // Controls if auto complete is shown when snippet fields are active. + // Only relevant if auto_complete_commit_on_tab is true. + "auto_complete_with_fields": false, + + // Controls what happens when pressing the up key while the first item in + // the auto complete window is selected: if false, the window is hidden, + // otherwise the last item in the window is selected. Likewise for the + // down key when the last item is selected. + "auto_complete_cycle": false, + + // Automatically close HTML and XML tags when </ is entered. + "auto_close_tags": true, + + // By default, shift+tab will only unindent if the selection spans + // multiple lines. When pressing shift+tab at other times, it'll insert a + // tab character - this allows tabs to be inserted when tab_completion is + // enabled. Set this to true to make shift+tab always unindent, instead of + // inserting tabs. + "shift_tab_unindent": false, + + // If true, the copy and cut commands will operate on the current line + // when the selection is empty, rather than doing nothing. + "copy_with_empty_selection": true, + + // If true, the selected text will be copied into the find panel when it's + // shown. + // On OS X, this value is overridden in the platform specific settings, so + // you'll need to place this line in your user settings to override it. + "find_selected_text": true, + + // When auto_find_in_selection is enabled, the "Find in Selection" flag + // will be enabled automatically when multiple lines of text are selected + "auto_find_in_selection": false, + + // When drag_text is enabled, clicking on selected text will begin a + // drag-drop operation. This is not currently implemented under Linux. + "drag_text": true, + + // + // User Interface Settings + // + + // The theme controls the look of Sublime Text's UI (buttons, tabs, scroll bars, etc) + "theme": "Default.sublime-theme", + + // Set to 0 to disable smooth scrolling. Set to a value between 0 and 1 to + // scroll slower, or set to larger than 1 to scroll faster + "scroll_speed": 1.0, + + // Controls side bar animation when expanding or collapsing folders + "tree_animation_enabled": true, + + // Controls animation throughout the application + "animation_enabled": true, + + // Makes tabs with modified files more visible + "highlight_modified_tabs": false, + + "show_tab_close_buttons": true, + + // Show folders in the side bar in bold + "bold_folder_labels": false, + + // OS X only: Set to true to disable Lion style full screen support. + // Sublime Text must be restarted for this to take effect. + "use_simple_full_screen": false, + + // OS X only. Valid values are true, false, and "auto". Auto will enable + // the setting when running on a screen 2560 pixels or wider (i.e., a + // Retina display). When this setting is enabled, OpenGL is used to + // accelerate drawing. Sublime Text must be restarted for changes to take + // effect. + "gpu_window_buffer": "auto", + + // Valid values are "system", "enabled" and "disabled" + "overlay_scroll_bars": "system", + + // Allows tabs to scroll left and right, instead of simply shrinking + "enable_tab_scrolling": true, + + // Display file encoding in the status bar + "show_encoding": false, + + // Display line endings in the status bar + "show_line_endings": false, + + // + // Application Behavior Settings + // + + // Exiting the application with hot_exit enabled will cause it to close + // immediately without prompting. Unsaved modifications and open files will + // be preserved and restored when next starting. + // + // Closing a window with an associated project will also close the window + // without prompting, preserving unsaved changes in the workspace file + // alongside the project. + "hot_exit": true, + + // remember_full_screen will allow Sublime Text to start in full screen + // mode if it was exited in full screen mode. When set to false, Sublime + // Text will never start in full screen mode. + "remember_full_screen": false, + + // Always prompt before reloading a file, even if the file hasn't been + // modified. The default behavior is to automatically reload a file if it + // hasn't been edited. If a file has unsaved changes, a prompt will always + // be shown. + "always_prompt_for_file_reload": false, + + // OS X only: When files are opened from finder, or by dragging onto the + // dock icon, this controls if a new window is created or not. + "open_files_in_new_window": true, + + // OS X only: This controls if an empty window is created at startup or not. + "create_window_at_startup": true, + + // Set to true to close windows as soon as the last file is closed, unless + // there's a folder open within the window. + // On OS X, this value is overridden in the platform specific settings, so + // you'll need to place this line in your user settings to override it. + "close_windows_when_empty": false, + + // Show the full path to files in the title bar. + // On OS X, this value is overridden in the platform specific settings, so + // you'll need to place this line in your user settings to override it. + "show_full_path": true, + + // Shows the Build Results panel when building. If set to false, the Build + // Results can be shown via the Tools/Build Results menu. + "show_panel_on_build": true, + + // Preview file contents when clicking on a file in the side bar. Double + // clicking or editing the preview will open the file and assign it a tab. + "preview_on_click": true, + + // folder_exclude_patterns and file_exclude_patterns control which files + // are listed in folders on the side bar. These can also be set on a per- + // project basis. + "folder_exclude_patterns": [".svn", ".git", ".hg", "CVS"], + "file_exclude_patterns": ["*.pyc", "*.pyo", "*.exe", "*.dll", "*.obj","*.o", "*.a", "*.lib", "*.so", "*.dylib", "*.ncb", "*.sdf", "*.suo", "*.pdb", "*.idb", ".DS_Store", "*.class", "*.psd", "*.db", "*.sublime-workspace"], + // These files will still show up in the side bar, but won't be included in + // Goto Anything or Find in Files + "binary_file_patterns": ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds", "*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip"], + + // File indexing parses all files in the side bar, and builds an index of + // their symbols. This is required for Goto Definition to work. + "index_files": true, + + // Set the number threads to use for indexing. A value of 0 will make + // Sublime Text guess based on the number of cores. Use the index_files + // setting to disable all workers. + "index_workers": 0, + + // index_exclude_patterns indicate which files won't be indexed. + "index_exclude_patterns": ["*.log"], + + // When enabled, anonymised usage data is sent back, assisting Sublime HQ + // in making informed decisions about improving Sublime Text. File names + // and file contents are never included, but data such as computer + // specifications, startup time, installed packages, and edited file types + // are. When disabled, telemetry is neither recorded or sent. + // A setting of auto will enable telemetry in dev builds, and disable + // telemetry in regular builds. + "enable_telemetry": "auto", + + // List any packages to ignore here. When removing entries from this list, + // a restart may be required if the package contains plugins. + "ignored_packages": ["Vintage"] +} diff --git a/C++/Preferences2.txt b/C++/Preferences2.txt new file mode 100644 index 0000000..7af229b --- /dev/null +++ b/C++/Preferences2.txt @@ -0,0 +1,35 @@ +{ + "auto_complete": true, + "caret_style": "solid", + "color_scheme": "Packages/User/SublimeLinter/Tomorrow-Night (SL).tmTheme", + "draw_white_space": "selection", + "find_selected_text": true, + "fold_buttons": false, + "font_face": "SourceCodePro-Medium", + "font_options": + [ + "subpixel_antialias", + "no_bold" + ], + "font_size": 14, + "highlight_line": true, + "highlight_modified_tabs": true, + "ignored_packages": + [ + "Vintage" + ], + "line_padding_bottom": 0, + "line_padding_top": 0, + "rulers": + [ + 72, + 79 + ], + "scroll_past_end": false, + "show_full_path": true, + "show_minimap": true, + "theme": "Soda Dark.sublime-theme", + "wide_caret": true, + "word_wrap": true, + "wrap_width": 80 +} diff --git a/C++/RawMemory.cpp b/C++/RawMemory.cpp new file mode 100644 index 0000000..f6247f6 --- /dev/null +++ b/C++/RawMemory.cpp @@ -0,0 +1,14 @@ +#include <iostream> +#include <string> + +using namespace std; + +int main() { + int a = 15; + int* point = &a; + + cout << "a: " << a << ", &a: " << &a << ", point: " + << point << ", &point: " << &point << ", *point: " << + *point << endl; + +}
\ No newline at end of file diff --git a/C++/RealEstate.cpp b/C++/RealEstate.cpp new file mode 100644 index 0000000..5f69c91 --- /dev/null +++ b/C++/RealEstate.cpp @@ -0,0 +1,60 @@ +#include <iostream> +#include <vector> +#include <string> +#include <cstdlib> +#include <sstream> +#include <fstream> + +using namespace std; + +void check_string(); +// void translate(stringstream); + +struct dict_type { + string false_m, real_m; +}; + +void check_string() { + ifstream dict_file; + dict_type dict; + vector<string> false_statement, real_statement, words; + stringstream statement; + string word, original; + + dict_file.open("DictRealEstate.txt"); + if(dict_file.is_open()){ + cout << "open\n"; + while(dict_file >> dict.false_m >> dict.real_m) { + false_statement.push_back(dict.false_m); + real_statement.push_back(dict.real_m); + } + cout << "finished...\n"; + dict_file.close(); + } + + cout << "Enter Statement: "; + getline(cin, original); + statement << original; + + while(statement >> word) { + words.push_back(word); + } + + for(int i = 0; i < words.size(); i++) { + for(int j = 0; j < false_statement.size(); j++) { + if(words[i] == false_statement[j]) { + words[i] = real_statement[j]; + } + } + } + cout << "Translation: "; + for(int k = 0; k < words.size(); k++) { + cout << words[k] << " "; + } + cout << endl; +} + +int main() { + check_string(); + return(0); +}
\ No newline at end of file diff --git a/C++/Recursion.cpp b/C++/Recursion.cpp new file mode 100644 index 0000000..21742ca --- /dev/null +++ b/C++/Recursion.cpp @@ -0,0 +1,41 @@ +#include <iostream> + +using namespace std; + +typedef int list_t; + +struct linkNode { + list_t element; + linkNode* next; +}; + +void addElement(linkNode*&, list_t&); +void addElementReverse(linkNode*&, list_t&); + +int main() { + linkNode* firstList = NULL; + linkNode* secondList = NULL; + + int n; + list_t el; + cout << "Number of elements in list: "; + cin >> n; + for(int i = 0; i < n; ++i) { + + } +} + +void addElement(linkNode* &hdList, list_t &el) { + linkNode* newNode = new linkNode; + newNode->element = el; + newNode->next = hdList; + hdList = newNode; +} + +void addElementReverse(linkNode* &hdList, list_t &el) { + if(hdList == NULL) { + + } else { + + } +} diff --git a/C++/SecondFile.txt b/C++/SecondFile.txt new file mode 100644 index 0000000..352813f --- /dev/null +++ b/C++/SecondFile.txt @@ -0,0 +1,5 @@ +Trump, Donald +Wiersema, Martin +Blanc, Alex +Herklotz, Yann +Wiggins, Sam diff --git a/C++/Sets.cpp b/C++/Sets.cpp new file mode 100644 index 0000000..cba50fc --- /dev/null +++ b/C++/Sets.cpp @@ -0,0 +1,63 @@ +m#include <iostream> +#include <cmath> +#include <vector> + +using namespace std; + +vector<int> v_union(vector<int>, vector<int>); +vector<int> v_intersection(vector<int>, vector<int>); +bool v_subset(vector<int>, vector<int>); + +vector<int> v_union(vector<int> v1, vector<int> v2) { + for(int i = 0; i < v2.size(); i++) { + bool present = false; + for(int j = 0; j < v1.size(); j++) { + if(v2[i] == v1[j]) { + present = true; + } + } + if(!present) { + v1.push_back(v2[i]); + } + } + return v1; +} + +vector<int> v_intersection(vector<int> v1, vector<int> v2) { + vector<int> vInt; + for(int i = 0; i < v2.size(); i++) { + for(int j = 0; j < v1.size(); j++) { + if(v2[i] == v1[j]) { + vInt.push_back(v2[i]); + } + } + } + return vInt; +} + +bool v_subset(vector<int> v1, vector<int> v2) { + for(int i = 0; i < v2.size(); i++) { + bool present = false; + for(int j = 0; j < v1.size(); j++) { + if(v1[j] == v2[i]) { + present = true; + } + } + if(!present) { + return false; + } + } + return true; +} + +int main() { + vector<int> a, b, c; + a.push_back(1); + a.push_back(2); + a.push_back(3); + b.push_back(1); + b.push_back(1); + b.push_back(2); + cout << v_subset(a, b) << endl; + return 0; +}
\ No newline at end of file diff --git a/C++/SumAndScalar.cpp b/C++/SumAndScalar.cpp new file mode 100644 index 0000000..04af50c --- /dev/null +++ b/C++/SumAndScalar.cpp @@ -0,0 +1,47 @@ +#include <iostream> +#include <cmath> +#include <vector> + +using namespace std; + +vector<double> vector_sum(vector<double>, vector<double>); +double vector_product(vector<double>, vector<double>); + +vector<double> vector_sum(vector<double> v1, vector<double> v2) { + vector<double> vSum; + for(int i = 0; i < v1.size(); i++) { + vSum.push_back(v1[i] + v2[i]); + } + return vSum; +} + +double vector_product(vector<double> v1, vector<double> v2) { + double vProduct; + for(int j = 0; j < v1.size(); j++) { + vProduct += v1[j] * v2[j]; + } + return vProduct; +} + +int main() { + vector<double> v1, v2, vSum; + double tmp, tmp2, vProduct; + int dimensions, x; + cout << "How many dimensions are you using? "; + cin >> dimensions; + do { + cout << "Please enter both vectors: "; + cin >> tmp >> tmp2; + v1.push_back(tmp); + v2.push_back(tmp2); + x++; + } while (x < dimensions); + vSum = vector_sum(v1, v2); + vProduct = vector_product(v1, v2); + cout << "Sum: "; + for(int k = 0; k < vSum.size(); k++) { + cout << vSum[k] << " "; + } + cout << "\nProduct: " << vProduct << endl; + return 0; +}
\ No newline at end of file diff --git a/C++/Surname.txt b/C++/Surname.txt new file mode 100644 index 0000000..a2e62ec --- /dev/null +++ b/C++/Surname.txt @@ -0,0 +1,5 @@ +Trump +Wiersema +Blanc +Herklotz +Wiggins
\ No newline at end of file diff --git a/C++/Test1.cpp b/C++/Test1.cpp new file mode 100644 index 0000000..a3ef13c --- /dev/null +++ b/C++/Test1.cpp @@ -0,0 +1,94 @@ +#include <iostream> +#include <cstdlib> +#include <fstream> +#include <sstream> +#include <string> +#include <vector> + +using namespace std; + +struct item { + string name; + int num; + + void print_str() { + cout << name << ": " << num << endl; + } +}; + +void merge_items(const vector<item> &vec1, vector<item> &vec2, vector<item> &vec_final) { + // bool running = false; + // for(int i = 0; i < vec1.size(); i++) { + // if(vec1[i].name == vec2[i].name) { + // vec2[i].num += vec1[i].num; + // vec_final.push_back(vec2[i]); + // } else if(vec1[i].name < vec2[i].name) { + // vec_final.push_back(vec1[i]); + // vec_final.push_back(vec2[i]); + // } else { + // vec_final.push_back(vec2[i]); + // vec_final.push_back(vec1[i]); + // } + // } + int count1, count2; + count1 = 0; + count2 = 0; + do { + if(count1 < vec1.size()) { + if(vec1[count1].name == vec2[count2].name) { + vec2[count2].num += vec1[count1].num; + vec_final.push_back(vec2[count2]); + count1++; + count2++; + } else if(vec1[count1].name < vec2[count2].name) { + vec_final.push_back(vec1[count1]); + count1++; + } else if(vec1[count1].name > vec2[count2].name) { + vec_final.push_back(vec2[count2]); + count2++; + } + } else { + vec_final.push_back(vec2[count2]); + count2++; + } + } while (vec_final.size() < vec1.size() + vec2.size()); + for(int i = vec1.size(); i < vec2.size(); i++) { + vec_final.push_back(vec2[i]); + } +} + +int main() { + string ware1, ware2; + ifstream fileware1, fileware2; + vector<item> vecware1, vecware2, vecfinal; + item tmpitem; + + ware1 = "Warehouse1.txt"; + ware2 = "Warehouse2.txt"; + + fileware1.open(ware1); + fileware2.open(ware2); + + if(!fileware1.is_open()) { + cout << "couldn't open fileware1: '" << ware1 << "'" << endl; + } + if(!fileware2.is_open()) { + cout << "couldn't open fileware2: '" << ware2 << "'" << endl; + } + + while(fileware1 >> tmpitem.name >> tmpitem.num) { + vecware1.push_back(tmpitem); + } + while(fileware2 >> tmpitem.name >> tmpitem.num) { + vecware2.push_back(tmpitem); + } + + merge_items(vecware2, vecware1, vecfinal); + for(int i = 0; i < vecfinal.size(); i++) { + cout << vecfinal[i].name << ": " << vecfinal[i].num << endl; + } + + fileware1.close(); + fileware2.close(); + return(0); +}
\ No newline at end of file diff --git a/C++/TestExample2.cpp b/C++/TestExample2.cpp new file mode 100644 index 0000000..fb7510f --- /dev/null +++ b/C++/TestExample2.cpp @@ -0,0 +1,55 @@ +#include <iostream> +#include <string> +#include <vector> + +using namespace std; + +struct codon_pairing { + string amino; + string codon; + + void prnt_pair() { + cout << amino << " " << codon << endl; + } +}; + +void wrong_entries(vector<codon_pairing>&, vector<codon_pairing>&, vector<codon_pairing>&); + +int main() { + vector<codon_pairing> experiment_log, correct_pair, wrong_pairs; + codon_pairing tmpcp; + + cout << "Please enter the experiment log (end end pair terminates):" << endl; + + do { + cin >> tmpcp.amino >> tmpcp.codon; + experiment_log.push_back(tmpcp); + } while(tmpcp.amino != "end" && tmpcp.codon != "end"); + + cout << "Please enter the known correct pairings (end end pair terminates):" << endl; + + do { + cin >> tmpcp.amino >> tmpcp.codon; + correct_pair.push_back(tmpcp); + } while(tmpcp.amino != "end" && tmpcp.codon != "end"); + wrong_entries(experiment_log, correct_pair, wrong_pairs); + cout << "Wrong entries:" << endl; + for(int i = 0; i < wrong_pairs.size(); ++i) { + wrong_pairs[i].prnt_pair(); + } +} + +void wrong_entries(vector<codon_pairing>& exp_log, vector<codon_pairing>& crrct_pair, vector<codon_pairing>& wrng_pairs) { + bool present = false; + for(int i = 0; i < exp_log.size(); ++i) { + for(int j = 0; j < crrct_pair.size(); ++j) { + if(exp_log[i].amino == crrct_pair[j].amino && exp_log[i].codon == crrct_pair[j].codon) { + present = true; + } + } + if(!present) { + wrng_pairs.push_back(exp_log[i]); + } + present = false; + } +}
\ No newline at end of file diff --git a/C++/TriangularDivisor.cpp b/C++/TriangularDivisor.cpp new file mode 100644 index 0000000..4e1278c --- /dev/null +++ b/C++/TriangularDivisor.cpp @@ -0,0 +1,29 @@ +#include <iostream> + +using namespace std; + +int main() { + int count, triangle, k, result; + int* allcount = new int[100000000000]; + k = 0; + result = 1; + for(int i = 2; i < 50000; ++i) { + triangle = (i*(i+1))/2; + int realtriangle = triangle; + for(int j = 2; j <= triangle; ++j) { + count = 0; + while(triangle % j == 0) { + triangle /= j; + ++count; + } + allcount[k] = count; + ++k; + } + for(int j = 0; j < k; ++j) { + result *= (allcount[j]+1); + } + if(result > 500) { + cout << realtriangle << endl; + } + } +}
\ No newline at end of file diff --git a/C++/Warehouse1.txt b/C++/Warehouse1.txt new file mode 100644 index 0000000..b334063 --- /dev/null +++ b/C++/Warehouse1.txt @@ -0,0 +1,5 @@ +apple 12 +banana 14 +mango 4 +orange 15 +pineapple 10
\ No newline at end of file diff --git a/C++/Warehouse2.txt b/C++/Warehouse2.txt new file mode 100644 index 0000000..8d564e6 --- /dev/null +++ b/C++/Warehouse2.txt @@ -0,0 +1,3 @@ +avocado 9 +banana 22 +papaya 5
\ No newline at end of file diff --git a/C++/smalltest.cpp b/C++/smalltest.cpp new file mode 100644 index 0000000..52e5044 --- /dev/null +++ b/C++/smalltest.cpp @@ -0,0 +1,16 @@ +#include <iostream> +#include <string> + +using namespace std; + +int main() { + string str1 = "Hello"; + string str2 = "Hella"; + if(str1 == str2) { + cout << str1 << " equals " << str2 << endl; + } else if(str1 < str2) { + cout << str1 << " is smaller than " << str2 << endl; + } else if(str1 > str2){ + cout << str1 << " is greater than " << str2 << endl; + } +} diff --git a/C++/w4.cpp b/C++/w4.cpp new file mode 100644 index 0000000..bef51a8 --- /dev/null +++ b/C++/w4.cpp @@ -0,0 +1,24 @@ +#include <iostream> +#include <vector> +#include <sstream> + +using namespace std; + +struct point { + double x; + double y; + + string returnString() { + stringstream ss; + ss << "(" << x << ", " << y << ")"; + return ss.str(); + } +}; + +int main() { + point userPt; + + cout << "Please enter a point: "; + cin >> userPt.x >> userPt.y; + cout << "Your point was: " << userPt.returnString() << endl; +} |