Joke Collection Website - Public benefit messages - Please help answer the questions in Tencent’s JAVA written test.
Please help answer the questions in Tencent’s JAVA written test.
1. Please define a macro to compare the size of two numbers a and b. You cannot use greater than, less than, or if statements
Answer:
#define max(a, b) ((((long)((a)-(b)))amp; 0x80000000)?b: a)
If a gt; b, then the highest binary bit of a-b is 0, and any number above is still 0, so the large number is a;
Otherwise, a-b is a negative number, the highest binary bit is 1, and the upper 0x80000000 (the highest bit is 1 and the others are 0) is 1 ,
So the largest number at this time is b.
2. How to output the title of the source file and the number of lines currently executed?
Answer: printf("The file name: d\n", __FILE__);
printf("The current line No: d\n", __LINE__);
ANSI C standard predefined macros:
__LINE__
__FILE__
__DATE__
__TIME__
__STDC__ This identifier is assigned a value of 1 when the program is required to strictly follow the ANSI C standard
__cplusplus__ This identifier is defined when writing a C program
3. No
4.while(1)
{
int *p = new int[10000];
}
5. Answer: A amp; B --gt; 2 mins
1 mins lt; -- A
C amp; D --gt; 10 mins
2 mins lt;-- B
A amp; B --gt; 2 mins
一*** 2 + 1 + 10 + 2 + 2 = 17 mins >
Hope this helps.
- Related articles
- There is a balance in the mobile card. Why do text messages always prompt that the balance is insufficient?
- What should I do if my iphone is stuck?
- Classic quotations from Valentine's Day on July 7th.
- Measures for the Management of Drowning Prevention among Primary and Secondary School Students in Hunan Province
- I just bought insurance for less than ten days ~ I haven't given the insurance policy yet! What if I want to surrender? But a short message sent me a contract number!
- How to query provident fund account information? Where can I check the provident fund account information?
- How to cancel Unicom's 4G exclusive Womailbox?
- Which style do you prefer when celebrities reveal their love affairs?
- Save the printing time of admission ticket.
- SMS fraud case in Zhengzhou, Henan Province