我想编写一个函数的getColor(),让我来提取输入为长提取一个十六进制数
十六进制数部分的“部分”的具体内容如下:
//prototype and declarations
enum Color { Red, Blue, Green };
int getColor(const long hexvalue, enum Color);
//definition (pseudocode)
int getColor(const long hexvalue, enum Color)
{
switch (Color)
{
case Red:
; //return the LEFTmost value (i.e. return int value of xAB if input was 'xABCDEF')
break;
case Green:
; //return the 'middle' value (i.e. return int value of xCD if input was 'xABCDEF')
break;
default: //assume Blue
; //return the RIGHTmost value (i.e. return int value of xEF if input was 'xABCDEF')
break;
}
}
我的'捣蛋'不是以前的样子。我将不胜感激这方面的一些帮助。
[编辑] 我改变了switch语句的颜色常量的顺序 - 毫无疑问,任何设计师,CSS爱好者在那里会注意到,颜色定义(在RGB比例)为RGB)
是不是真的__Green__中间值? 见http://en.wikipedia.org/wiki/Rgb#The_24-bit_RGB_representation: (255,0,0)是红色 (0,255,0)是绿色 (0,0,255)是蓝色的 – DNNX