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
0367 - Eliminare Cifre
(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!
=== Rezolvare ver. 2 === <syntaxhighlight lang="python" line> # citim numarul de numere n si verificam daca se incadreaza in limitele impuse nr_de_numere = int(input("Introduceti numarul de numere: ")) while nr_de_numere < 1 or nr_de_numere > 1000: nr_de_numere = int(input("Numarul introdus nu este valid. Introduceti un numar intre 1 si 1000: ")) # initializam variabila suma cu 0 suma = 0 # iteram prin cele n numere for i in range(nr_de_numere): # citim numarul si verificam daca se incadreaza in limitele impuse numar = int(input("Introduceti numarul " + str(i + 1) + ": ")) while numar < 0 or numar > 999999: numar = int(input("Numarul introdus nu este valid. Introduceti un numar mai mic sau egal cu 999999: ")) # obtinem ultima cifra a numarului ultima_cifra = numar % 10 # eliminam toate aparitiile ultimei cifre din numar numar_fara_ultima_cifra = 0 putere = 1 while numar > 0: cifra = numar % 10 numar //= 10 if cifra != ultima_cifra: numar_fara_ultima_cifra += cifra * putere putere *= 10 # adaugam numarul fara ultima cifra la suma totala suma += numar_fara_ultima_cifra # afisam suma totala print("Datele au fost introduse corect.") print("Suma numerelor obtinute prin eliminarea aparitiilor ultimei cifre din fiecare numar este:", suma) </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