I want to put a variable in the code to see the result value, but I don't know where and how to put it.

Asked 2 years ago, Updated 2 years ago, 32 views

 n = int(sys.stdin.readline())
    point = []
    for _ in range(n):
        a, b = map(int, sys.stdin.readline().split())
        point.append([a, b])
    xold, yold = point.pop(0)
    Point.append([xold, yold]) # After selecting the starting point, add the starting point again at the end.
    area = 0
    while point:
        nx, ny = point.pop(0)
        area += (old +ny) * (nx - xold) / 2 # Add trapezoidal width
        xold, yold = nx, ny
    print("%.1f" % abs(area))

C (n) It's a code to find the width of a square This is what I drew on the canvas,

I logarithmically took the coordinate values of the squares in the figure

Where should I put this coordinate value as a variable to calculate the result value in print statement??

python

2022-09-20 08:43

1 Answers

point = [
    [38, 58],
    [38, 59],
    [38, 60],
    [38, 61],
    [38, 62],
    [38, 63],
    [38, 64],
    [38, 65],
    [39, 66],
]

xold, yold = point.pop(0)
Point.append([xold, yold]) # After selecting the starting point, add the starting point again at the end.
area = 0
while point:
    nx, ny = point.pop(0)
    area += (old +ny) * (nx - xold) / 2 # Add trapezoidal width
    xold, yold = nx, ny
print("%.1f" % abs(area))

You can do this under the assumption that you use the code as much as you can.


2022-09-20 08:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.