Tag: 原始

洪水填充算法

我正在使用turbo C ++在C中使用一个简单的图形库,因为我正在开发一个非常原始版本的绘画风格程序,每个都运行良好,但我无法使洪水填充算法工作。 我使用4路泛洪填充算法,首先我尝试使用递归版本,但它只适用于小区域,填充大区域使其崩溃; 阅读我发现实现它的显式堆栈版本解决了问题,但我没有真正看到它。 我开发了这样的堆栈: struct node { int x, y; struct node *next; }; int push(struct node **top, int x, int y) { struct node *newNode; newNode = (struct node *)malloc(sizeof(struct node)); if(newNode == NULL) //If there is no more memory return 0; newNode->x = x; newNode->y = y; newNode->next = *top; *top […]