2911 - Write Digits: Difference between revisions
Paul Ungur (talk | contribs) |
Paul Ungur (talk | contribs) |
||
| Line 12: | Line 12: | ||
== Exemplu == | == Exemplu == | ||
; Intrare | ; Intrare | ||
: | : 1234567890 | ||
; Ieșire | ; Ieșire | ||
: Datele de intrare corespund restricțiilor impuse. | : Datele de intrare corespund restricțiilor impuse. | ||
@ | |||
@@ | |||
@ | |||
@ | |||
@@@@@ | |||
@@@@ | |||
@ @ | |||
@ | |||
@ | |||
@@@@ | |||
@@@@@ | |||
@ | |||
@@@@@ | |||
@ | |||
@@@@@ | |||
@ @ | |||
@ @ | |||
@@@@@ | |||
@ | |||
@ | |||
@@@@@ | |||
@ | |||
@@@@@ | |||
@ | |||
@@@@@ | |||
@@@@@ | |||
@ | |||
@@@@@ | |||
@ @ | |||
@@@@@ | |||
@@@@ | |||
@ | |||
@@@ | |||
@ | |||
@ | |||
@@@@@ | |||
@ @ | |||
@@@@@ | |||
@ @ | |||
@@@@@ | |||
@@@@@ | |||
@ @ | |||
@@@@@ | |||
@ | |||
@ | |||
@@@@@ | |||
@ @ | |||
@ @ | |||
@ @ | |||
@@@@@ | |||
<br> | <br> | ||
; Intrare | ; Intrare | ||
| Line 31: | Line 86: | ||
: Datele de intrare nu corespund restricțiilor impuse. | : Datele de intrare nu corespund restricțiilor impuse. | ||
<br> | <br> | ||
== Rezolvare == | == Rezolvare == | ||
=== Rezolvare ver. 1 === | === Rezolvare ver. 1 === | ||
Revision as of 20:03, 21 April 2023
Sursa: 4294 - Perechi N
Cerinţa
Se dă un număr natural n. Să se afișeze fiecare cifră a numărului folosind simbolul @, ca în exemplu.
Date de intrare
Programul citește de la tastatură numărul n.
Date de ieșire
Programul va afișa pe ecran fiecare cifră a numărului citit scrisă. După fiecare cifră se va lăsa un rând gol.
Restricţii şi precizări
1 ≤ n ≤ 1010
Exemplu
- Intrare
- 1234567890
- Ieșire
- Datele de intrare corespund restricțiilor impuse.
@ @@ @ @
@@@@@
@@@@ @ @
@ @
@@@@
@@@@@
@
@@@@@
@
@@@@@
@ @ @ @ @@@@@
@ @
@@@@@ @ @@@@@
@
@@@@@
@@@@@ @ @@@@@ @ @ @@@@@
@@@@
@ @@@ @ @
@@@@@ @ @ @@@@@ @ @ @@@@@
@@@@@ @ @ @@@@@
@ @
@@@@@ @ @ @ @ @ @ @@@@@
- Intrare
- abc
- Ieșire
- Datele de intrare nu corespund restricțiilor impuse.
- Intrare
- -25
- Ieșire
- Datele de intrare nu corespund restricțiilor impuse.
Rezolvare
Rezolvare ver. 1
<syntaxhighlight lang="python" line>
- 4294 - Perechi N
def validare_date_numar(numar: str) -> bool:
if numar.isdigit():
if 1 <= int(numar) <= 100:
return True
return False
def perechin(numar: int):
for termen1 in range(1, numar // 2 + 1):
termen2 = numar - termen1
print(termen1, termen2)
if __name__ == "__main__":
numar = input()
if validare_date_numar(numar):
numar = int(numar)
print("Datele de intrare corespund restricțiilor impuse.")
perechin(numar)
else:
print("Datele de intrare nu corespund restricțiilor impuse.")
</syntaxhighlight>