C#中的四色图问题 [英] Four Color Map Problem in C#
本文介绍了C#中的四色图问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我是这个网站上的新手,我尝试学习C#。
我有一个关于四色问题的问题。我需要做一个以win形式模拟四个颜色贴图的应用程序。我知道如何使用回溯在控制台应用程序中做,但我尝试使用相同的算法以win形式做但我不知道如何绘制。
anyoane可以帮我提供如何实现这个或完整应用程序源代码的源代码吗?
谢谢!
Hello, i'm new on this site and i try to learn C#.
I have a question about the four color problem. I need to do an aplication that simulate the four color maps in win forms. I know how to do in console application using backtracking, but i tried to do in win form using the same algorithm but i don't know how to draw.
Can anyoane help me with source code of how i can implement this or with source code of the entirely application ?
Thanks!
推荐答案
不,这是你的作业,你应该自己做,不要标记我们做什么! :笑:
使用Winforms绘图很简单:只需处理Form或Panel的Paint事件,并使用提供的Graphics上下文。
例如,这将绘制一个与红色圆圈重叠的绿色矩形:
No, this is your homework, and you are expected to do it yourself, not get marked on what we do! :laugh:
Drawing in Winforms is easy: just handle the Paint event for a Form or Panel, and use the supplied Graphics context.
For example, this will draw a Green Rectangle overlapping a Red Circle:
private void myPanel_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.FillEllipse(Brushes.Red, 100, 100, 200, 200);
g.FillRectangle(Brushes.Green, 150, 150, 50, 50);
}
所以试试吧,试验一下,看看会发生什么!
So try it, experiment, and see what happens!
这篇关于C#中的四色图问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文