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
0138 - Frecventa
(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 == <syntaxhighlight lang="python" line="1"> # 0138 Frecventa def verificare(sir_chr): # functia de validare a datelor de intrare for caracter in sir_chr: if 122 < ord(caracter) < 97: if ord(caracter) != ord(" "): # caracterul trebuie sa fie litera sau spatiu return False return True def frecventa(sir): nr_alfabet = [] # vectorul de frecventa in care numaram fiecare litera din alfabet for i in range(123): nr_alfabet.append(0) for caracter in sir: # numaram fiecare litera din sir in vectorul de frecventa nr_alfabet[ord(caracter)] += 1 max_aparitii = max(nr_alfabet[97:]) # aflam numarul maxim de aparitii for i in range(len(nr_alfabet)): if nr_alfabet[i] == max_aparitii and i >= 97: # parcurgem sirul, daca gasim caracterul cu numar maxim de aparitii si e o litera il afisam print(chr(i)) return if __name__ == '__main__': sir_caractere = input("Introduceti sirul de caractere: ") # citirea sirului if verificare(sir_caractere): # verificarea datelor de intrare print("Datele introduse corespund restricțiilor impuse.") frecventa(sir_caractere) # apelul functiei de rezolvare else: print("Datele introduse nu corespund restricțiilor impuse.") </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