Problem

5 /13


Rearrangement of words

Theory Click to read/hide

Unfortunately, there is no function in Pascal that would allow reading multiple space-separated lines from a single line. To do this, you have to write your own function:

vars, w: string;
i, j, ind: integer;
a: array of string;

begin
    readln(s);
    setlength(a, length(s));
    i := 1;
    ind := 0;
    while i < length(s) do
    begin
        while (i < length(s)) and ('' + s[i] = ' ') do i += 1;
        j := i + 1;
        w := '' + s[i];
        while (j < length(s)) and ('' +s[j] <> ' ') do begin
            w += s[j];
            j += 1;
        end;
        a[ind] := w;
        ind += 1;
        i := j;
    end;
    write(a[0], a[1]);
end.

As a result, we get an array of strings.

Problem

The input is one line containing the last name and first name of the person (separated by exactly one space).
 
Print the same information, but first name and then last name.
 
Example
# Input Output
1 Pupkin Vasya Vasya Pupkin