home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume17
/
contest-prog
/
part02
/
prob4.txt
< prev
next >
Wrap
Text File
|
1989-02-06
|
864b
|
49 lines
Problem 4: Print odds and evens side-by-side.
The input file will consist of some positive integers. The number
of integers will be less than thirty. Each integer will be
greater than or equal to one. The last line of the input file
will contain a negative number, for use as a sentinel. There will
be one integer per line, left justified, beginning in column 1.
The output is to consist of lines of the form:
odd number even number
where the numbers are those from the input file, in the order in
which they occurred.
If there are fewer odd numbers than even numbers, pad with -1 .
If there are fewer even numbers than odd numbers, pad with -1 .
Do not output a line consisting of -1 -1 .
Example input file:
9
8
12
13
2
4
-1
The output should be:
9 8
13 12
-1 2
-1 4
Another example file:
9
11
13
2
4
7
-1
The output should be
9 2
11 4
13 -1
7 -1