Ministério da Educação
Brasil um país de todos
Personal tools
You are here: Home Members Rodrigo Soares Laboratório de programação Exercícios Exercício 2 - Resolvido
Navigation
Log in


Forgot your password?
 
Document Actions

Exercício 2 - Resolvido

by Rodrigo Soares last modified 2014-10-10 12:23

Click here to get the file

Size 1 kB - File type text/python-source

File contents

with open("E1.in","r") as fin:
    retA = fin.readline()
    retA = retA.split()
    retB = fin.readline()
    retB = retB.split()
ax1=float(retA[0])
ay1=float(retA[1])
ax2=float(retA[2])
ay2=float(retA[3])
bx1=float(retB[0])
by1=float(retB[1])
bx2=float(retB[2])
by2=float(retB[3])

if ax1<bx1:
    if ax2>bx1: #candidato ok para eixo x
        if ay1<by1:
            if ay2>=by1:
                colide="1"
            else:
                colide="0"
        else:
            if ay1<=by2:
                colide="1"
            else:
                colide="0"
    else:
        colide="0"
else:
    if ax1<=bx2: #candidato ok para eixo x
        if ay1<by1:
            if ay2>=by1:
                colide="1"
            else:
                colide="0"
        else:
            if ay1<=by2:
                colide="1"
            else:
                colide="0"
    else:
        colide="0"

with open("E2.out","w") as fout:
    fout.write(colide + "\n")

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: