MP_02 Modifikation 1

This commit is contained in:
Johannes Theiner 2018-03-20 12:16:03 +01:00
parent a1c05e422a
commit 7bfc780c81
4 changed files with 17 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View File

@ -23,21 +23,35 @@ return value;
} }
int hexStringToInt(PascalString binaryDigits) { int hexStringToInt(PascalString binaryDigits) {
int returnValue = -1; int returnValue = 0;
for(int i = 0; i <= binaryDigits.length; ++i) {
returnValue += binaryDigits.characters[i];
}
return returnValue; return returnValue;
} }
void printPascalString(PascalString s) {
for(int i = 0; i <= s.length; i++) {
println(s.characters[i]);
}
}
int main(int argc, char** argv, char** envp) { int main(int argc, char** argv, char** envp) {
PascalString s = {3, '1', '0', '0'}; PascalString s = {3, '1', '0', '0'};
PascalString s2 = {4, 'f', 'f', 'f', 'f'}; PascalString s2 = {4, 'f', 'f', 'f', 'f'};
println(hexStringToInt(s)); println(hexStringToInt(s));
println(hexStringToInt(s2)); println(hexStringToInt(s2));
println(hexDigitToInt('d'));
println(hexDigitToInt('D'));
println(hexDigitToInt('9')); println(hexDigitToInt('9'));
println(hexDigitToInt('2')); println(hexDigitToInt('2'));
printPascalString(s2);
return 0; return 0;
} }

Binary file not shown.