home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: WPS_PM / WPS_PM.zip / ICONPL2.ZIP / SAMPLES.ARC / ROMAN.ICN < prev   
Text File  |  1985-09-08  |  612b  |  24 lines

  1. #
  2. #          R O M A N   N U M E R A L S
  3. #
  4.  
  5. #  This program takes Arabic numerals from standard input and writes
  6. #  the corresponding Roman numerals to standard outout.
  7.  
  8. procedure main()
  9.    local n
  10.    while n := read() do
  11.       write(roman(n) | "cannot convert")
  12. end
  13.  
  14. procedure roman(n)
  15.    local arabic, result
  16.    static equiv
  17.    initial equiv := ["","I","II","III","IV","V","VI","VII","VIII","IX"]
  18.    integer(n) > 0 | fail
  19.    result := ""
  20.    every arabic := !n do
  21.       result := map(result,"IVXLCDM","XLCDM**") || equiv[arabic+1]
  22.    if find("*",result) then fail else return result
  23. end
  24.