TOPIC

Wrong Answer (10%) em Python 3

Alcides Dias asked 2 years ago

Se alguém puder me explicar onde está o erro, agradeço muito! Já fiz vários testes e até agora não descobri.

X = float(input())
cont = 0
if X < 0:
    if int(X) == X or (X < 0 and X < -1):
        xv = str(int(X))
        if len(xv) > 1:
            X = X / (10 ** int((len(xv) -2)))
        print("%.4f" % X, end='')
        print("E+", end='')
        if int((len(xv) - 1)) < 10:
            print("0", end='')
        print(int((len(xv) - 2)))
    elif X < 0 and X > -1:
        X = X * -1
        while X < 1:
            X = X * 10
            cont += 1
        print("-", end="")
        print("%.4f" % X, end='')
        print("E-", end="")
        if cont < 10:
            print("0", end='')
        print(cont)
elif X > 0:
    xv = str(int(X))
    if len(xv) > 1:
        X = X / (10 ** int((len(xv)-1)))
    print("+", end='')
    print("%.4f" % X, end='')
    print("E+", end='')
    if int((len(xv)-1)) < 10:
        print("0", end='')
    print(int((len(xv)-1)))
else:
    if str(X) == "-0.0":
        print("-0.0000E+00")
    else:
        print("+0.0000E+00")

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.