close

 

上帝幫你關了一扇門,就會幫你開一扇窗,

所以,我打算幫準備寫考卷的你 / 妳 開一扇窗,

我將答案放在我的blog裡面,

如果你有看到,請背起來,

這樣你期待薪資的地方,

才有可能成真。

 

 

 

 

 

 

 

 

1. Please write the following print.

     char s[] = "0113256";

     char *p = s;

     printf("%c", *p++);

     printf("%c", *(p++));

     printf("%c", (*p)++);

     printf("%c", *++p);

     printf("%c", *(++p));

     printf("%c", ++*p);

     printf("%c", ++(*p));

 

     printf("\n");

     printf(s);

1.___________

2.___________

 

2. Please write the following print.

union AA

{

     char a[2];

     int s;

};

 

int main()

{

     AA aa = { 0 };

     aa.a[0] = 12;

     aa.a[1] = 1;

     printf("%x\n", aa.s);

     printf("%d\n", sizeof(aa));

     getchar();

     return 0;

}

1.___________

2.___________

 

3.

#define XPROC(X) X*X

 

int main()

{

     int n = XPROC(2 + 3);

     cout << n << endl;

}

n = _________

 

4.Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.

Example 1:

Input: "Let's take LeetCode contest"

Output: "s'teL ekat edoCteeL tsetnoc"

 

Note: In the string, each word is separated by single space and there will not be any extra space in the string.

 

class Solution

{

public:

     string reverseWords(string s)

     {

          

 

 

 

         return s;

     }

};

 

 

 

 

 

 

 

 

 

1.

0113234

0123456

 

 

2.

printf("%x\n", aa.s);   = 10c

printf("%d\n", sizeof(aa));  =4

 

3.

n = 11

關於這題,因已不是第一次有人詢問,所以稍微講解一下,

題目是

#define XPROC(X) X*X

int n = XPORC(2+3);

然後問 n = 多少,

這部分是要考Macro的概念,其實還蠻簡單的,

就是將Macro展開,就這樣

也就是說,我們可以把這題看成是

int n = 2+3*2+3

這樣結果,就是等於11了

 

 

4.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

arrow
arrow
    全站熱搜

    Eric 發表在 痞客邦 留言(3) 人氣()