MP_02 Modifikation 1
This commit is contained in:
parent
a1c05e422a
commit
7bfc780c81
BIN
02_MENT/a.out
BIN
02_MENT/a.out
Binary file not shown.
Binary file not shown.
|
@ -23,21 +23,35 @@ return value;
|
|||
}
|
||||
|
||||
int hexStringToInt(PascalString binaryDigits) {
|
||||
int returnValue = -1;
|
||||
int returnValue = 0;
|
||||
|
||||
for(int i = 0; i <= binaryDigits.length; ++i) {
|
||||
returnValue += binaryDigits.characters[i];
|
||||
}
|
||||
|
||||
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) {
|
||||
PascalString s = {3, '1', '0', '0'};
|
||||
PascalString s2 = {4, 'f', 'f', 'f', 'f'};
|
||||
println(hexStringToInt(s));
|
||||
println(hexStringToInt(s2));
|
||||
|
||||
|
||||
println(hexDigitToInt('D'));
|
||||
println(hexDigitToInt('d'));
|
||||
println(hexDigitToInt('9'));
|
||||
println(hexDigitToInt('2'));
|
||||
|
||||
printPascalString(s2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue