to solve 'Valuation', I've written a small piece of C#-code.
Code: Select all
static int recalc(int dx) {
return dx - 48;
}
[...]
while(cnt < arrText.Length) {
if (false == Char.IsDigit(arrText[cnt])) { // if 'x' occurs, set it to zero and move left
arrText[cnt] = '0'; // write ASCII-'0' as char ('48' in dec)
cnt -= 2; // go two steps left
}
int x = recalc((int)arrText[cnt]); // casting from char to int delivers ASCII-value in dec. To get the digit itself, recalc() subtracts 48 from each value.
sum += x;
cnt++;
}
Can someome give me a hint?
Thank you.