一些很好的例子使用枚举 [英] Some good example for using enums

查看:128
本文介绍了一些很好的例子使用枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我学到枚举当我得知C和时不时我让自己提醒一下,大部分时间由某些源重新阅读,它发生,我认为这是由于这一事实,我从来没有使用它在我的节目,我的编程兴趣集中围绕算法解决问题的,所以我不知道在那里我可不可以用枚举。

I learned enums when I learned C and from time to time I keep myself reminding about it and most of the time by re-reading from some source,it occurred to me that this is due to the fact I never use it in my programming,my programming interest concentrate around algorithmic problem solving so I am not sure where could I possibly use enums.

可能有人提出了一些很好的例子,用枚举是让事情变得更容易?

Could somebody suggest some good example where using enums is makes things much easy?

我想AP preciate算法的例子,但两者的算法或者非算法的例子是值得欢迎的。

I would appreciate algorithmic examples but both of algorithmic or non-algorithmic examples are welcome.

推荐答案

试想一下,你正在编写深度优先搜索,你想与他们是否是树,后退,前进,或交叉标记您的边缘。你可以创建具有四种可能性枚举EDGE_TYPE并用它来标记您的边缘。

Imagine that you are programming a depth first search and you want to tag your edges with whether they are tree, back, forward, or cross. You could create an enum EDGE_TYPE with the four possibilities and use it to tag your edges.

这篇关于一些很好的例子使用枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆