Re: select
- Posted by Ad Rienks <kwibus at ZONNET.NL> Sep 02, 2000
- 495 views
------=_NextPart_000_0006_01C0150F.271A4660 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Ferdinand wrote: Hi coders and friends. I have a little problem . I want to select the number closest to the = number that is inputed by the user . Example : I have two numbers , 10 and 30 . the = user inputs the number 25 , so the program MUST select the number = closest , and that number is 30 . How can I do this ? Thanks . O, and by the way , I just made my first = REAL program , a awsome sprite editor . And you can save the pic you = made to files in sequences e.g. {1,12,66,8,29 ....... . And it took me = 30 min flat ! Its realy easy now . Ferdinand Interesting! I'm sure people like to see your sprite editor. Underneath is my solution to your problem: -- tested code! include get.e integer low, high, input object key low =3D 10 high =3D 30 input =3D 25 if (input - low) < (high - input) then printf(1, "%d is the closest", low) else printf(1, "%d is the closest", high) end if key =3D wait_key() -- find out for yourself what to do when input < low or input > high -- end of tested code ----- Oorspronkelijk bericht -----=20 Van: =0E=20 Aan: EUPHORIA at LISTSERV.MUOHIO.EDU=20 Verzonden: zaterdag 2 september 2000 6:06 Onderwerp: select Hi coders and friends. I have a little problem . I want to select the number closest to the = number that is inputed by the user . Example : I have two numbers , 10 = and 30 . the user inputs the number 25 , so the program MUST select the = number closest , and that number is 30 . How can I do this ? Thanks . O, = and by the way , I just made my first REAL program , a awsome sprite = editor . And you can save the pic you made to files in sequences e.g. = {1,12,66,8,29 ....... . And it took me 30 min flat ! Its realy easy now = .=20 Ferdinand ------=_NextPart_000_0006_01C0150F.271A4660 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV>Ferdinand wrote:</DIV> <DIV> </DIV> <DIV>Hi coders and friends.</DIV> <DIV> </DIV> <DIV>I have a little problem . I want to select the number closest to = the number=20 that is<BR>inputed by the user . Example : I have two numbers , 10 and = 30 . the=20 user inputs the number 25 , so the program MUST select the number = closest , and=20 that number is 30 .<BR>How can I do this ? Thanks . O, and by the way , = I just=20 made my first REAL program , a awsome sprite editor . And you can save = the pic=20 you made to files in sequences e.g. {1,12,66,8,29 ....... . And it took = me 30=20 min flat ! Its realy easy now .</DIV> <DIV> </DIV> <DIV>Ferdinand</DIV> <DIV> </DIV> <DIV>Interesting! I'm sure people like to see your sprite = editor.</DIV> <DIV>Underneath is my solution to your problem:</DIV> <DIV> </DIV> <DIV>-- tested code!</DIV> <DIV> </DIV> <DIV>include get.e</DIV> <DIV> </DIV> <DIV>integer low, high, input<BR>object key</DIV> <DIV> </DIV> <DIV>low =3D 10<BR>high =3D 30<BR>input =3D 25</DIV> <DIV> </DIV> <DIV>if (input - low) < (high - input) then<BR> = printf(1,=20 "%d is the closest", low)<BR>else<BR> printf(1, "%d is = the=20 closest", high)<BR>end if</DIV> <DIV> </DIV> <DIV>key =3D wait_key()</DIV> <DIV> </DIV> <DIV>-- find out for yourself what to do when input < low or input = >=20 high</DIV> <DIV>-- end of tested code</DIV> <BLOCKQUOTE=20 style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: = 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px"> <DIV style=3D"FONT: 10pt arial">----- Oorspronkelijk bericht ----- = </DIV> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>Van:</B>=20 <A href=3D"mailto:mwfch at MWEB.CO.ZA" title=3Dmwfch at MWEB.CO.ZA>=0E</A> = </DIV> <DIV style=3D"FONT: 10pt arial"><B>Aan:</B> <A=20 href=3D"mailto:EUPHORIA at LISTSERV.MUOHIO.EDU"=20 title=3DEUPHORIA at LISTSERV.MUOHIO.EDU>EUPHORIA at LISTSERV.MUOHIO.EDU</A> = </DIV> <DIV style=3D"FONT: 10pt arial"><B>Verzonden:</B> zaterdag 2 september = 2000=20 6:06</DIV> <DIV style=3D"FONT: 10pt arial"><B>Onderwerp:</B> select</DIV> <DIV><BR></DIV> <DIV><FONT face=3DArial>Hi coders and friends.</FONT></DIV> <DIV>I have a little problem . I want to select the number closest to = the=20 number that is inputed by the user . Example : I have two numbers , 10 = and 30=20 . the user inputs the number 25 , so the program MUST select the = number=20 closest , and that number is 30 . How can I do this ? Thanks . O, and = by the=20 way , I just made my first REAL program , a awsome sprite editor . And = you can=20 save the pic you made to files in sequences e.g. {1,12,66,8,29 ....... = . And=20 it took me 30 min flat ! Its realy easy now . </DIV> <DIV> </DIV> ------=_NextPart_000_0006_01C0150F.271A4660--