From b75b7e169a28881dd4ea012f45a15724291c37dd Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Mon, 9 Apr 2018 21:22:13 +0200 Subject: [PATCH] =?UTF-8?q?und=20weiter=20geht=20der=20Spa=C3=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02_MENT/main_02_MENT.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/02_MENT/main_02_MENT.cpp b/02_MENT/main_02_MENT.cpp index 399fe6b..630d83c 100644 --- a/02_MENT/main_02_MENT.cpp +++ b/02_MENT/main_02_MENT.cpp @@ -80,13 +80,18 @@ PascalString intToHex(int n) { } +int getInt(char character) { + if(character == '0') return character; + else return '1'; +} + PascalString bitwiseDualAnd(PascalString a, PascalString b) { PascalString result = {a.length, '0'}; for(int i = b.length; i >= 0; --i) { if(a.length < i) result.characters[i] = a.characters[i]; - println("i: ", i, " ", a.characters[i] & b.characters[i]); - result.characters[i] = a.characters[i] & b.characters[i]; + println("i: ", i, " ", intToHexChar(getInt(a.characters[i]) & getInt(b.characters[i]))); + result.characters[i] = intToHexChar(getInt(a.characters[i]) & getInt(b.characters[i])); } return result;