MP_02 irgendwas
This commit is contained in:
parent
df99b0273a
commit
34ee2fb962
|
@ -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
|
|
@ -0,0 +1,20 @@
|
|||
// file: main_02_MENT.cpp
|
||||
// THIS IS C++, use clang++
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
BIN
02_MENT/a.out
BIN
02_MENT/a.out
Binary file not shown.
|
@ -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;
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -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++;
|
||||
|
|
Loading…
Reference in New Issue