|
|
back to boardplot Posted by ASK 8 Apr 2018 22:13 if your program is /tmp/a.out and the input is /tmp/in, you can use the following Python 3 script to plot your output: from matplotlib.pyplot import * import subprocess f = open('/tmp/in') n = int(f.readline()) p = [[int(i) for i in l.split()] for l in f] print(p) out = subprocess.run('/tmp/a.out < /tmp/in', stdout=subprocess.PIPE, shell=True).stdout.decode().strip() res = [int(s) for s in out.split('\n')[1:]] print(res) plot([v[0] for v in p],[v[1] for v in p],'ro') plot([p[i-1][0] for i in res], [p[i-1][1] for i in res],'b-') axis('equal'); grid(); show() |
|
|