|
|
int x = n + m;
|
|
Enter a0 a1 a2: 2 2 5 Enter b0 b1 b2: 6 5 5 225 655 1141 Program ended with exit code: 0 |
-3 -2 -1 0 1 2 3 (alien) ↓ 0 1 2 3 4 5 6 (human) |
Well, seems as if OP has very ignorantly removed his question. |
@kemort Er... because you asked...? |
corestorm wrote: |
---|
So i've got a problem from a computer science class. I can't figure out the algorithm. Basically it goes like this. if i have a system where i have an "alien aged 3" and he has 3 fingers on each hand left side is -3 - 2 - 1 his head counts as 0 and the right hand is 1 2 3 I need to sum up inputs So I take his (age * 2 + 1) and that gives you the 'base' Age: 3 alien = base 7 -3 -2 -1 0 1 2 3 would be the counting system so lets say i have this sequence of inputs from the user here's what the answer is when you add in this strange number system, keep in mind the user can only put 6 integers in. 6 variable input 1 -2 3 1 0 -1 6 variable input + 2 0 3 3 -1 -3 ------------- = 3-1-3 0 -2 3 so -1 + -3 = 3 the way this works is you count -3 from -1 and it goes to the 3 so 3 carry -1 to 0 + -1 which is -2 now i get how that works my problem is this I need to make an algorithm where i don't use any loops any if statements and just use variables and pure math to solve this. Does anyone have any idea how to do this ? i would greatly appreciate the help. |
|
|
Enter a0 a1 a2: 1 1 1 Enter b0 b1 b2: 3 3 3 1 1 1 3 3 3 0 1 1 -2 Program ended with exit code: 0 |