14i.cpp
来自「《C/C++程序设计导论(第二版)》一书的程序源文件」· C++ 代码 · 共 17 行
CPP
17 行
#include <iostream.h>
// colors() Separate a 16-bit RGB pixel into individual colors
// IN: pixel is a 16-bit RGB value
// OUT: red, green, and blue are returned as individual color values
void colors (int pixel, int& red, int& green, int& blue)
{ const int FIVEBITS = 0x1F; // lower 5 bits are 1's
red = (pixel >> 10) & FIVEBITS;
green = (pixel >> 5) & FIVEBITS;
blue = pixel & FIVEBITS;
}
void main ()
{ int red, green, blue, pixel = 0x1234;
colors (pixel, red, green, blue);
cout << red << "," << green << "," << blue << endl;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?