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
3284 - Calc Par Impar
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
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!
== Explicații == Acest cod este o implementare a unei probleme care primește un număr n de valori și apoi n valori naturale. Scopul este să se calculeze valoarea maximă pară dintre toate pozițiile pare și valoarea minimă impară care are exact două cifre în reprezentarea sa. Funcția citeste_n() primește numărul de valori de la utilizator și se asigură că această valoare este între 2 și 20. Funcția returnează această valoare n. Funcția citeste_valori(n) citește n valori de la utilizator și se asigură că fiecare valoare este între 1 și 1.000.000.000. Aceste valori sunt adăugate într-o listă și această listă este returnată. Funcția calcParImpar(valori) calculează valoarea maximă pară dintre toate pozițiile pare și valoarea minimă impară care are exact două cifre în reprezentarea sa. Pentru a face acest lucru, funcția parcurge toate valorile din lista și verifică dacă poziția este pară sau impară. Dacă poziția este pară, atunci valoarea este verificată și, dacă este pară și mai mare decât valoarea maximă pară curentă, atunci valoarea devine noua valoare maximă pară. Dacă poziția este impară, atunci valoarea este verificată și, dacă are exact două cifre și este mai mică decât valoarea minimă impară curentă, atunci valoarea devine noua valoare minimă impară. Funcția nrcif(n) primește o valoare întreagă și returnează numărul de cifre din reprezentarea acelei valori. În funcția principală, citeste_n() și citeste_valori(n) sunt apelate pentru a citi valorile de la utilizator, apoi calcParImpar(valori) este apelată pentru a calcula valorile dorite.
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