diff --git a/02_MENT/Testat/build.sh b/02_MENT/Testat/build.sh new file mode 100755 index 0000000..7efe4e7 --- /dev/null +++ b/02_MENT/Testat/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +rm *.out + +clang++-6.0 -std=c++14 -I../helpers/ -o limits.out limits_println.cpp +clang++-6.0 -std=c++14 -I../helpers/ -o println.out printlnDemo.cpp + +clang++-6.0 -std=c++14 main_02_MENT.cpp + +./a.out diff --git a/02_MENT/Testat/main_02_MENT.cpp b/02_MENT/Testat/main_02_MENT.cpp new file mode 100644 index 0000000..1cead71 --- /dev/null +++ b/02_MENT/Testat/main_02_MENT.cpp @@ -0,0 +1,20 @@ +// file: main_02_MENT.cpp +// THIS IS C++, use clang++ + +#include + +#include "../../helpers/println.hpp" + +struct PascalString{ + int length; // number of chars used + char characters[256]; // chars of some character string +}; + +int main(int argc, char** argv, char** envp) { + + PascalString s = {3, '1', '0', '0'}; + PascalString s2 = {4, 'f', 'f', 'f', 'f'}; + + return 0; +} + diff --git a/02_MENT/a.out b/02_MENT/a.out index 6ce0451..b8a6f54 100755 Binary files a/02_MENT/a.out and b/02_MENT/a.out differ diff --git a/02_MENT/main_02_MENT.cpp b/02_MENT/main_02_MENT.cpp index 185eb92..120d199 100644 --- a/02_MENT/main_02_MENT.cpp +++ b/02_MENT/main_02_MENT.cpp @@ -32,8 +32,6 @@ int hexStringToInt(PascalString binaryDigits) { return returnValue; } - - void printPascalString(PascalString s) { for(int i = 0; i <= s.length; i++) { println(s.characters[i]); @@ -49,11 +47,49 @@ PascalString intToDual(int n) { n = n / 2; i--; } - - return string; } +char intToHexChar(int n) { + if(n > 9) { + switch(n) { + case 10: return 'A'; break; + case 11: return 'B'; break; + case 12: return 'C'; break; + case 13: return 'D'; break; + case 14: return 'E'; break; + case 15: return 'F'; break; + default: return 'X'; + } + } + else return n + '0'; +} + +PascalString intToHex(int n) { + int i = std::to_string(n).length(); + PascalString string = {i}; + while(n >= 1) { + string.characters[i] = intToHexChar(n % 16); + n = n / 16; + i--; + } + return string; + +} + +PascalString bitwiseDualAnd(PascalString a, PascalString b) { + PascalString shortString = a.length < b.length ? a : b; + PascalString longString = a.length > b.length ? a : b; + PascalString result = {longString.length, '0'}; + + for(int i = longString.length; i >= 0; --i) { + if(shortString.characters[i] == '1' && longString.characters[i] == '1') result.characters[i] = '1'; + else result.characters[i] = '0'; + } + + return result; +} + int main(int argc, char** argv, char** envp) { PascalString s = {3, '1', '0', '0'}; @@ -75,7 +111,14 @@ int main(int argc, char** argv, char** envp) { println(controlRegister); - printPascalString(intToDual(41)); + println(intToHexChar(6)); + println(intToHexChar(10)); + + printPascalString(intToDual(4106)); + printPascalString(intToHex(965)); + printPascalString(intToHex(1956)); + + printPascalString(bitwiseDualAnd({3, '1', '1', '0'}, {4, '1', '1', '1', '0'})); return 0; } diff --git a/03_FLOW_a/flow.out b/03_FLOW_a/flow.out index 9c7cb79..cb7fd54 100755 Binary files a/03_FLOW_a/flow.out and b/03_FLOW_a/flow.out differ diff --git a/03_FLOW_a/main_mp2_FLOW_a.cpp b/03_FLOW_a/main_mp2_FLOW_a.cpp index 4811c4c..6ee6c86 100644 --- a/03_FLOW_a/main_mp2_FLOW_a.cpp +++ b/03_FLOW_a/main_mp2_FLOW_a.cpp @@ -115,10 +115,12 @@ int func_1(int arg){ PRINT; return arg * local_1; } - +void modifikation1(); +void modifikation2(); int main(int argc, const char * argv[]) { + /* console.clearScreen(); currentColor = Colors::BLUE; @@ -146,13 +148,35 @@ int main(int argc, const char * argv[]) { currentColor = Colors::MAGENTA; test(); + */ + + console.clearScreen(); + currentColor = Colors::BLUE; + modifikation1(); + currentColor = Colors::RED; + modifikation2(); + std::string s; std::cin >> s; + return 0; } +void modifikation1() { + INITPRINT("Modifikation 1"); + PRINT; + PRINT; + PRINT; + PRINT; + PRINT; +} + +void modifikation2() { + +} + void printLineNumber(int lineNumber){ std::string line = std::to_string(lineNumber); currentTick++;