Impaired Glucose Test

Source: Internet
Author: User

Today, I went to the China site for an hour's written test on the student's C ++ questions. There were 10 questions in total.

All the questions are in English, and the answer should also be in English.

1. sizeof output of different basic data types and pointers in 32-bit and 64-bit situations

2. Differences between Conditional compilation program segments and common program segments

3. Concepts of virtual tables and virtual pointers and Their Relationships

4. Application of function pointers

5. constructor and destructor of the base class and derived class

6. Differences and relationships between processes and threads

7. Differences between the capacity () and size () functions of vector

8. Describe the three features of c ++

9. Implementation of the reverse operation algorithm for a single-chain table

10. The program implements the output of all combinations of mathematical combinations.

Suppose our set is {1, 2, 3}. We will scan the elements of the set from scratch. The first element is 1. For this element, we can place it in the combination set, and then select it in the remaining set; or we can leave it in the combination set, select the elements in the remaining set and put them in the combination set. In general, assume that our set has n elements and requires a combination of m elements. We can scan every element. For this element, we can place it in the combination set, and then select the -1 element in the remaining n-1 elements. We can also leave this element in the set, select m elements from the n-1 elements. This is already a clear idea of recursion. The specific code is as follows.

Void combination (char * src, int num, vector <char> & result)
{
If (num = 0)
{
Vector <char>: iterator iter = result. begin ();
For (; iter <result. end (); iter ++)
{
Printf ("% c", * iter );
}
Printf ("\ n ");
Return;
}
If (* src = '\ 0') return;
Result. push_back (* src );
Combination (src + 1, num-1, result );
Result. pop_back ();
Combination (src + 1, num, result );
}

Void all_sub_set (char * src)
{
Assert (src );
If (! Src) return;
Int I = 0;
Int len = strlen (src );
Vector <char> result;


For (I = 1; I <= len; I ++)
{
Combination (src, I, result );
}
}

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.