Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Bitnami MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
3114 - abq
(section)
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= Exemplu = <code>cifre_romane.in</code> 4 <code>cifre_romane.out</code> IV == Rezolvare == <syntaxhighlight lang="python3"> import sys def convert_to_roman(num): """Converts a given number from Arabic numerals to Roman numerals.""" roman_numerals = { 1: "I", 5: "V", 10: "X", 50: "L", 100: "C", 500: "D", 1000: "M" } result = "" while num > 0: # Find the largest Roman numeral that is less than or equal to the current number for key in sorted(roman_numerals.keys(), reverse=True): if num >= key: result += roman_numerals[key] num -= key break return result def main(): """Reads input and converts numbers to Roman numerals.""" num = int(input()) # Check if the number is within the valid range if 1 <= num <= 3999: roman_numeral = convert_to_roman(num) print(roman_numeral) else: print("Numarul nu este in intervalul valid (1 β€ N β€ 3999).") if __name__ == "__main__": sys.stdin = open("cifre_romane.in") sys.stdout = open("cifre_romane.out", "w") main() sys.stdin.close() sys.stdout.close() </syntaxhighlight>
Summary:
Please note that all contributions to Bitnami MediaWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Bitnami MediaWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width