C ++ pen questions: one of the two answers

Source: Internet
Author: User

C ++ pen questions: one of the two answers

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 ".

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;

Solve the second question.



Two business pen questions

1.
A: 50 Years Old
B: 32 years old
Other three: 49, 10, and 5
A: There are 7 combinations that meet the condition that the three numbers are multiplied by 2450. However, the sum of the two values is equal to 64 (10, 5, 49, 50, 7, and 7. Therefore, the age of B is 32. But Jia said that three people are younger than Jia, which means Jia is 50 years old, while the other three are 10, 5, and 49.

2. Select the box labeled as two fruits. If it is an apple, it must be an apple basket. The rest marked with an apple is an orange, and the rest marked with an orange is two fruits.
Similarly, if it is an orange, the box must be an orange basket, and the rest marked with oranges is an apple, which must be two fruits.
(For such logic questions, just sort out your ideas. If you do not have any ideas, you can also use exclusion. -- Certainly cannot select the basket of apples or oranges. Because the two are essentially the same, you can only select one of the three distinctive ones)

Two simple c # pen questions to answer (The Problem Solving Process)

You can use the treeview control class or xml class.

Excuse me, could you give me 400 points? I found that I could upgrade after 400 points.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.