DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Invert Number

 
   Reply to topic    DELPHI AREA Forum Index -> Delphi Programming
View previous topic :: View next topic  
Author Message
mouse
Member


Joined: 07 Oct 2003
Posts: 8

PostPosted: 01/12/03 07:43    Post subject: Invert Number Reply with quote

I am very New In Programming
I find Problem

How can I invert Number like 103 to 301

I am try But Need help
Code:
program rr;
var y,x:integer;
begin
while y<>0  do
begin
readln(x);
y:= x mod 10;
writeln(y);
end;
x:=x div 10;
readln;
end;

_________________
Mouse @@@
Back to top
View user's profile
Johnny_Bit
Junior Member


Joined: 15 Jun 2003
Posts: 98

PostPosted: 01/12/03 13:47    Post subject: Reply with quote

If you want to invert string representation of number in Delphi it's simple:

Code:

var
  num, revnum, i:integer;
  s1, s2: string;
begin
  S1:=IntToStr(num);
  for I:=Length(S1) downto 1 do
    S2:=S2+S1[I]
  revnum:=strtoint(s2);
end;
Back to top
View user's profile
mouse
Member


Joined: 07 Oct 2003
Posts: 8

PostPosted: 01/12/03 14:14    Post subject: Reply with quote

Thanks
it`s simple but I am also beginner

_________________
Mouse @@@
Back to top
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 250

PostPosted: 01/12/03 17:55    Post subject: Reply with quote

And, for the integer values as follow:

Code:
function MirrorNumber(Value: Integer): Integer;
begin
  Result := 0;
  while Value <> 0 do
  begin
    Result := Result * 10 + Value mod 10;
    Value := Value div 10;
  end;
end;
Back to top
View user's profile Send e-mail Visit poster's website
Display posts from previous:   
   Reply to topic    DELPHI AREA Forum Index -> Delphi Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB 2.0.6 © 2001, 2002 phpBB Group