[ atlas @ 05.03.2005. 00:39 ] @
treba mi program u Pascalu koji ce za unesenu recenicu ispisati istu,sa istim redoslijedom reci ali obrnutim poretkom slova...

primjer

MAJA IDE U SUMU.
--> AJAM EDI U UMUS.


[ Toyo @ 05.03.2005. 01:26 ] @
Evo ti u delphi-ju. Trebalo bi da je isto i u paskalu (ne mogu da se setim dal ima copy ili nesto drugo).

Code:

function Obrni(S: String): String;
var R,Res: String;
  Poz,I: Integer;
begin
  Res:='';
  while s<>'' do
    begin
      Poz :=pos(' ',S);
      if Poz = 0 then
        Poz := Length(S)+1;
      R:= copy(S,1,Poz-1);
      S:= copy(S,Poz+1,255);
      for I:= Length(R) downto 1 do
        Res := Res + copy(R,i,1);
      if S<>'' then
        Res := Res+' ';
    end;
    Obrni := Res;
end;


[ bancika @ 05.03.2005. 01:39 ] @
Code:

var s, s1: string;
     pocetak, j, i: Integer;
begin
  ReadLn(s); s1 := '';
  i := 1;
  while i <= Length(s) do
   begin
     while (i<=Length(s)) and not (UpCase(s[i]  in ['A'..'Z']) do
      Inc(i);
     Pocetak := i;
    while (i<=Length(s)) and (UpCase(s[i]  in ['A'..'Z']) do
      Inc(i);
    for j := i downto pocetak do s1 := s1 + s[j];
   end;
  WriteLn(s1)
end

ovo je onako iz glave, mozda (verovatno) ne radi, ali eto ti ideje
[ atlas @ 05.03.2005. 23:57 ] @
Imal neko ideju preko for,goto strukture za ovaj program
[ sasas @ 06.03.2005. 01:18 ] @
ss.

Code:

var
  i: byte;
  ulaz, rec, rezultat: string[255];
begin
  readln(ulaz);
  for i := byte(ulaz[0]) downto 1 do
    if ulaz[i] = ' ' then begin
      rezultat := rec + ' ' + rezultat;
      rec := '';
    end else rec := rec + ulaz[i];
  rezultat := rec + ' ' + rezultat;
  writeln(rezultat);
end.