Skip to content

Commit

Permalink
Merge pull request #453 from juniorjse/master
Browse files Browse the repository at this point in the history
Adicionando questões - 1022, 1097, 1098, 1101
  • Loading branch information
ummatias authored Oct 1, 2021
2 parents b218a51 + 356477a commit 26c40ca
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
40 changes: 40 additions & 0 deletions prog1/implementacoes/uri/1022.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
def operacao(num1, dig1, opt, num2, dig2):
if opt == '+':
num = (num1 * dig2) + (num2 * dig1)
dem = dig1 * dig2

if opt == '-':
num = (num1 * dig2) - (num2 * dig1)
dem = dig1 * dig2

if opt == '*':
num = num1 * num2
dem = dig1 * dig2

if opt == '/':
num = num1 * dig2
dem = num2 * dig1

return num, dem

def fatoramento(a, b):
abs_a, abs_b = abs(a), abs(b)
men = min(abs_a, abs_b)
mai = max(abs_a, abs_b)
divisor = men
while divisor > 1:
if (men % divisor) == 0:
if (mai % divisor) == 0:
return int(a/divisor), int(b/divisor)
divisor -= 1
return a, b


var = int(input())

for x in range(0, var):
operacoes = input().strip().split(' ')
n1, d1, op, n2, d2 = int(operacoes[0]), int(operacoes[2]), operacoes[3], int(operacoes[4]), int(operacoes[6])
num, dem = operacao(n1, d1, op, n2, d2)
simp_num, simp_dem = fatoramento(num, dem)
print(f'{num}/{dem} = {simp_num}/{simp_dem}')
9 changes: 9 additions & 0 deletions prog1/implementacoes/uri/1097.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
i = 1
j = 7

while i <= 9:
for c in range(1, 4):
print(f"I={i} J={j}")
j = j - 1
i = i + 2
j = j + 5
17 changes: 17 additions & 0 deletions prog1/implementacoes/uri/1098.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Junior Silva - 120110464
#UFCG
j = 1
soma = 0.2
n = i = 0

while i <= 2:
for c in range(1, 4):
if i > 2.19:
print(f"I={2:.0f} J={j:.0f}")
if i == 0.0 or i == 1.0 or i > 1.8:
print(f"I={i:.0f} J={j:.0f}")
elif i < 2:
print(f"I={i:.1f} J={j:.1f}")
j = j + 1
i = i + soma
j = 1 + i
23 changes: 23 additions & 0 deletions prog1/implementacoes/uri/1101.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
num_aux = mai = men = 0
trava = True

while trava:
n1, n2 = map(int, input().split())
if(n1 <= 0 or n2 <= 0):
break

mai = n1 if n1 > n2 else n2
men = n2 if n2 < n1 else n1

if mai > men :
num_aux = mai
mai = men
men = num_aux

soma = 0

while mai <= men :
print(mai, end=' ')
soma += mai
mai+=1
print(f"Sum={soma}")

0 comments on commit 26c40ca

Please sign in to comment.