Arabic numerals converted to Roman numerals

Source: Internet
Author: User

Title: Roman numerals are derived from the ancient Roman coding system. They are based on the combination of a particular letter of the alphabet, and the number represented is equal to the number of these numbers (or subtract). The top ten Roman numerals are: I,ii,iii,iv,v,vi,vii,viii,ix and X. The Roman notation system is not directly based on the decimal, it has no zeros. Roman numerals are based on the combination of these seven symbols: symbolic value i 1  (unus) v 5  (quinque) x 10  (DECEM) l 50  ( Quinquaginta) c 100  (centum) d 500  (Quingenti) m 1,000  (Mille) additional information about the Roman numerals can be found in   Wikipedia article. In this task, you should return a Roman number with a range from 1 to 3999 for the specified integer value. Enter:  an integer   (int). Output:  A string representation of Roman numerals   (str). Prerequisite: 0 < number <  4000 test data: 6764993888 correct result: VILXXVICDXCIXMMMDCCCLXXXVIII problem-solving ideas: The number from large to small split, need to grasp the law, in turn, the results are saved to the list, and finally printed out. Script: Def operate (DATA,&NBSP;DIVISOR,&NBSP;STR1,&NBSP;STR2,&NBSP;STR3):     result =   '     temp = data // divisor    if temp :        if temp >= 5:             if temp == 9:                result = str1 +  str3                temp  -= 9            else:                 result = str2                 temp -= 5         if temp:             if temp == 4:                 result += str1 + str2             else:                 result += str1 * temp        return  resultdef checkio (data):     result = []    temp  = data // 1000    if temp:         result.append (' M '  * temp)         data %=  1000    temp = operate (data, 100,  ' C ',  ' D ',  ' M ')      if temp:        result.append (temp)          data %= 100    temp = operate (data , 10,  ' X ',  ' L ',  ' C ')     if temp:         result.append (temp)         data %= 10     temp = operate (data, 1,  ' I ',  ' V ',  ' X ')     if temp:         result.append (temp)     return  '. Join ( Result


This article is from the "Last Night Stars" blog, please make sure to keep this source http://yestreenstars.blog.51cto.com/1836303/1661691

Arabic numerals converted to Roman numerals

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.