c++笔试题两道,求解其中一道
2014-09-19 10:46
239 查看
1.Implement a functionthat prints the numbers from 1 to 100.But for multiples of three(3) print “Zif”insteadof the number and for the multiples of five(5) print “Nab”. For numbers whichare multiples
of both three and five print “ZifNab”.
2. unsigned short ConvertRGB888toRBG565(unsigned int nSourceColor)
Parameters: nSourceColor – 32 Bits RGB color to convert.
Return: The converted color as a 16 Bits RGB color.
This function converts an RGB 32 bits color format to RGB 16 bits color format. The 32 bits formats contains 8 bits of empty padding.8 bits for RED.8 bits for GREEN and 8 bits for BLUE. In that order. Now you have to down convert
this value to 16 bits. By have 5 bits for RED, 6 bits for GREEN and finally 5 bits for the BLUE.
Color Help:
Red = 0x00FF0000
Green = 0x0000FF00;
Blue = 0x000000FF;
White = 0x00FFFFFF;
Black = 0x00000000;
第二题求解。
of both three and five print “ZifNab”.
void printZifNab(int from, int to) { if (from > to) return; for (int i = from; i <= to; i++) { if ((i % 3 == 0) && (i % 5 == 0)) { printf("ZifNab\n"); } else if ((i % 3 == 0)) { printf("Zif\n"); } else if ((i % 5 == 0)) { printf("Nab\n"); } else { printf("%d\n", i); } } }
2. unsigned short ConvertRGB888toRBG565(unsigned int nSourceColor)
Parameters: nSourceColor – 32 Bits RGB color to convert.
Return: The converted color as a 16 Bits RGB color.
This function converts an RGB 32 bits color format to RGB 16 bits color format. The 32 bits formats contains 8 bits of empty padding.8 bits for RED.8 bits for GREEN and 8 bits for BLUE. In that order. Now you have to down convert
this value to 16 bits. By have 5 bits for RED, 6 bits for GREEN and finally 5 bits for the BLUE.
Color Help:
Red = 0x00FF0000
Green = 0x0000FF00;
Blue = 0x000000FF;
White = 0x00FFFFFF;
Black = 0x00000000;
第二题求解。
相关文章推荐
- c++笔试题两道,求解当中一道
- 程序员面试题精选(40):一道SPSS笔试题求解
- 一道关于C++派生类初始化的笔试题
- 腾讯2013年校园招聘笔试,其中的两道关于fork()的题目
- 每天一道C++笔试题 III --- strcmp
- 百度2013年校园招聘一道笔试题--三位密码组合问题递归求解
- 群硕一道笔试题(java,c++)
- C++及Windows异常处理(try,catch; __try,__finally; __try, __except)——一道笔试题引起的探究
- 一道关于C++ 继承/虚函数 笔试题
- 【校园招聘】一道笔试题看c++中virtual覆盖
- 两道出现频率超高的C++笔试题
- 一道迅雷笔试题引发的..写给不知道c/c++序列点的人(转)
- 每天一道C++笔试题 II
- 每天一道C++笔试题 I
- [c++]输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数。(写的代码有疑惑,求解求教)
- [C/C++]一道指针,内存布局的笔试题[摘自CSDN]
- 一道c++笔试题
- 一道笔试题,求解
- 一道c++笔试题
- C++及Windows异常处理(try,catch; __try,__finally; __try, __except)——一道笔试题引起的探究