•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 456,475 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,770 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser: Programming Forums
Views: 2272 | Replies: 11
![]() |
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
•
•
Join Date: Jun 2006
Location: Blumenau, Brazil
Posts: 71
Reputation:
Rep Power: 3
Solved Threads: 4
Just another way to do this - introducing recursivity:
Bye
pascal Syntax (Toggle Plain Text)
function Reverse(var value :string; start :integer) :string; var StrTmp :string; begin if start <= length(value) then begin StrTmp := ''; // getting the word while (start <= length(value)) and (value[start] <> ' ') do begin StrTmp := StrTmp +value[start]; Inc(start); end; // preserve spaces and put it before the word while value[start] = ' ' do begin StrTmp := ' ' +StrTmp; Inc(start); end; // recursive call to get the next word and insert it before the actual - StrTmp Reverse := Reverse(value, start) +StrTmp; end else ReverseWord := ''; end; var sl :string; begin readln(sl); sl := Reverse(sl, 1); writeln(sl); end.
"It always has, at least, two ways to make one same thing. Exactly that they are certain and wrong"(Micheus)
Brazil - Blumenau
Brazil - Blumenau
![]() |
•
•
•
•
•
•
•
•
DaniWeb Pascal and Delphi Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
Other Threads in the Pascal and Delphi Forum
- Previous Thread: level counter in a label... help pls
- Next Thread: Unbelievably simple question



Linear Mode