plottour.c
来自「Travelling saleman by C++」· C语言 代码 · 共 45 行
C
45 行
/* * plotTour.c * * Phil Cox, B00XXXXXX * Login: pcox * CSCI2132: Assignment 3 * */#include <stdio.h>#include "list.h"void plotTour(struct node *tour){ /* * Print postscript code depicting a given tour */ struct node *curr; if (tour == NULL) return; printf("%%!\n50 50 translate\n0 0 512 512 rectstroke\n"); /* plot the tour's edges */ printf("%5.1f %5.1f moveto\n", 512.0*tour->x, 512.0*tour->y); printf("1.0 0.0 0.0 setrgbcolor\n"); for (curr=tour->next; curr != NULL; curr=curr->next) printf("%5.1f %5.1f lineto\n", 512.0*curr->x, 512.0*curr->y); printf("closepath stroke\n"); /* plot dots marking the locations of the nodes */ printf("0.0 0.0 0.0 setrgbcolor\n"); for (curr=tour; curr!=NULL; curr = curr->next) { printf("newpath\n"); printf("%5.1f %5.1f 2 0 360 arc\n", 512.0*curr->x, 512.0*curr->y); printf("closepath\nfill\n"); } printf("showpage\n");}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?