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
2817 - Identice 4
(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!
= Exemplul 1 = Input: a=700 b=1500 Output: 777 888 999 1111 == Exemplul 2 == Input: a=-1 b=2 Output: nu exista == Rezolvare == <syntaxhighlight lang="python3" line="1"> def cifre_identice(numar): """ Verifică dacă toate cifrele unui număr sunt identice. :param numar: Numărul de verificat. :return: True dacă toate cifrele sunt identice, False în caz contrar. """ cifra = numar % 10 # Se obține ultima cifră numar_temporar = numar // 10 while numar_temporar > 0: if numar_temporar % 10 != cifra: return False numar_temporar //= 10 return True def identice(a, b): """ Afișează numerele naturale din intervalul [a, b] care au toate cifrele identice. :param a: Primul număr natural din interval (10≤a≤b≤1000000). :param b: Al doilea număr natural din interval (10≤a≤b≤1000000). """ a = max(a, 10) # Asigurăm că a este cel puțin 10 exista_numere_identice = False for numar in range(a, min(b + 1, 1000001)): if cifre_identice(numar): print(numar, end=' ') exista_numere_identice = True if not exista_numere_identice: print("nu exista") # Exemplu de apel: a = 700 b = 1500 identice(a, b) </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