For C++ programmers .. how can I solve this problem pleasee :[ !!?

Guys, I really have a hard day seeing this that I can't find a solution yet and It should be delivered by tomorrow 4:00 AM Maximum.

The question: https://s18.postimg.org/9w847ybkp/2017-04-02_14-03-59.jpg


Let n=akak-1ak-2…a1a0 be an integer and t=a0-a1 + a2……+(-1)k ak. it is known that n is divisible
by 11 if only if ( t) is divisible by 11. For example, suppose that n=8784204, then t=(4-0)+(2-
4)+(8-7)+8 and equal to 11 and it is divisible by 11. Write a program that prompts the user to
enter a positive integer number and then uses this criterion to determine whether the number is
divisible by 11.

a. Create a look up table holding a0 - a1 for all one or two digit numbers a1a0 ie. for numbers in [00,99]


b. Implement function t(n)
for n == akak-1 ... a3a2a1a0, t(n) == (a0-a1) + (a2-a3) + (a4-a3) + ...

if n < 100, t(n) == look_up_table[n]
else t(n) == look_up_table[n%100] + t(n/100)



c. Implement function bool divisible_by_11(n)

if n < 10 return true if n == 0, false otherwise
else return divisible_by_11( t(n) )


Spoiler: http://coliru.stacked-crooked.com/a/bb94a048152af61d
Topic archived. No new replies allowed.