Add column width

This commit is contained in:
flyingscorpio@pinebookpro 2022-01-17 13:00:58 +01:00
parent a64106f262
commit 703341f267

View file

@ -7,6 +7,7 @@ Calcule le PGCD de deux nombres et trouve les coefficients de Bezout.
import sys
def main():
assert len(sys.argv) == 3
a = int(sys.argv[1])
@ -30,10 +31,14 @@ def main():
print_table(r, u, v, q)
def print_table(r, u, v, q):
"""Représentation de l'algorithme"""
width = max((len(str(i)) for i in r))
for i in range(len(r)):
print(f"{r[i]:^5} {u[i]:^5} {v[i]:^5} {q[i]:^5}")
print(f"{r[i]:^{width}} {u[i]:^{width}} {v[i]:^{width}} {q[i]:^{width}}")
if __name__ == "__main__":