我想編寫一個函數的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