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
3327 - La Scoala
(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 2 == ; Intrare : n ; Iesire : Datele introduse nu corespund restricțiilor impuse. <syntaxhighlight lang="python" line> # 3327 - La Scoala import math # Functia de verificare a datelor de intrare def verificare_restrictii(n1): if 1 <= n1 <= 1000: return True else: return False # Functia premiati calculeaza numarul de elevi premiati si k def premiati(n1): k1 = int(math.sqrt(n1)) ** 2 premiantii = n1 - k1 return premiantii, k1 # Functia aranjare creeaza o matrice k x k cu elevii nepremiati def aranjare(k1): p = int(math.sqrt(k1)) elevii = [[0] * p for _ in range(p)] numar = k1 for i in range(p): for j in range(p): elevii[i][j] = numar numar -= 1 return elevii # Functia afisare printeaza matricea pe ecran def afisare(elevii): for rand in elevii: print(' '.join(map(str, rand))) # In main citim numarul de elevi, calculam numarul de premianti si aranjam elevii nepremiati if __name__ == "__main__": try: n = int(input()) if verificare_restrictii(n): print("Datele introduse corespund restricțiilor impuse.") premianti, k = premiati(n) print(premianti) elevi = aranjare(k) afisare(elevi) else: print("Datele de intrare nu corespund restrictiilor impuse.") except ValueError: print("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