避免使用If / Else语句 [英] avoid If/Else statements
问题描述
嗨
任何人都可以帮助我...我需要在代码中避免使用If / else语句。我已经搜索过,但我无法解决这个问题。
据说它使用向量。但我不想使用那些向量。或者模板。
我需要在代码中避免使用If / else语句。
我能想到的就是为什么?
删除单个最有用和最常用的控制结构听起来像是一个很好的程序给我的食谱。
所有我能想到要说的是为什么?
删除单个最有用和最常用的控制结构听起来不像是一个良好形成的程序给我。
我们不需要steenkin''if-else语句;我们可以在没有它们的情况下做得好,因为我们有着名的?:三元运算符;它也适用于混淆。
亲切的问候,
Jos; - )
< blockquote class =post_quotes>
嗨
任何人都可以帮助我......我需要在代码中避免使用If / else语句。我已经搜索过,但我无法解决这个问题。
据说它使用向量。但我不想使用那些向量。或模板。
我同意Banfa,为什么?无论如何,你可以使用一个更容易阅读的switch语句,实际上比if语句更有效。但是,您只能使用具有主要类型(int,double,char)的switch case。
我想你可以欺骗一个while循环或者成为一个if语句。但是,任何阅读你的代码的人都想扯掉他们的眼睛。
Hi
Could any one help me ... I need to avoid If / else statements in my code. I have searched but I could not any simple solution for that.
Its said to use vectors.But I ddont want to use those vectors. or templates.
I need to avoid If / else statements in my code.All I can think of to say is why?
Removing the single most useful and most used control structure does not sound like a receipe for a well formed program to me.
All I can think of to say is why?
Removing the single most useful and most used control structure does not sound like a receipe for a well formed program to me.We don''t need no steenkin'' if-else statements; we can do well without them as
long as we''ve got the famous ?: ternary operator; it works better for obfuscation too.
kind regards,
Jos ;-)
Hi
Could any one help me ... I need to avoid If / else statements in my code. I have searched but I could not any simple solution for that.
Its said to use vectors.But I ddont want to use those vectors. or templates.I agree with Banfa, why? At any rate, you can use a switch statement which is easier to read and actually more effective than if else statement. However, you can only use switch cases with primative types (int, double, char).
I guess you can trick a while loop or for to be an if statement. However, anyone reading your code would want to rip their eyes out.
这篇关于避免使用If / Else语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!