Jump to content

[help] hard algorithm

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Jim_West

Jim_West

    Newbie

  • Members
  • Pip
  • 1 posts
Hey,
I'm sorry for my bad english.

I have a problem with an algorithm,
the function get 2 integers - x and y, the function resturn string that shows how can you get y with only use addition - + .

function show(int x,int y)
example 1 :
x = 2345
y = 239
234+5
example 2 :
x= 1612345
y=130


I only understood for three-digit number - you only got 3 options :
x+y+z
x+yz
xy+z

Please Help Me !

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
You have to treat the number as a string, and break it up the various ways.

You can also use integer division and modulus to split it by using powers of 10 as the divisor.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog