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
2346 - Paritate Siruri
(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"> # 2346 Paritate Siruri def validare(nr_prop, propozitii): # functia de validare a datelor de intrare if nr_prop <= 0 or nr_prop >= 100: raise ValueError # daca datele de intrare nu corespund, ridicam eroarea ValueError if len(propozitii) != nr_prop: raise ValueError for prop in propozitii: if len(prop) > 10000: raise ValueError for litera in prop: if (litera < 'a' or litera > 'z') and (litera < 'A' or litera > 'Z'): # trebuie sa fie doar litera raise ValueError file_out.write("Datele de intrare corespund restrictiilor impuse\n") def paritate_siruri(siruri): # functia de rezolvare for sir in siruri: file_out.write(sir[1::2] + " " + sir[::2] + "\n") # din 2 in 2 afisat, intai de la pozitia 1 apoi de la 0 if __name__ == '__main__': file_in = open("paritatesiruriin.txt", "r") # declararea fisierelor file_out = open("paritatesiruriout.txt", "w") # din cauza datelor de intrare pot aparea 2 tipuri de erori, valueError sau IndexError pe care le tratam try: nr_siruri = int(file_in.readline()) # citirea numarului de siruri lista_siruri = [] for i in range(nr_siruri): propozitie = file_in.readline().strip() # citim fiecare propozitie si prin .strip() scapam de spatii sau \n de la final lista_siruri.append(propozitie) # adaugam textul intr-o lista de siruri de caractere validare(nr_siruri, lista_siruri) # apelul functiei de validare paritate_siruri(lista_siruri) # apelul functiei de rezolvare except ValueError: file_out.write("Datele de intrare nu corespund restrictiilor impuse") except IndexError: file_out.write("Datele de intrare nu corespund restrictiilor 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