腾讯实习生笔试的一道题

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 
 5 int main()
 6 {
 7     int nR = 1;
 8     
 9     const char as[] = "tencent";
10     if ("tencent" == as)
11     {
12         nR = nR + 1;
13         printf("1
");
14     }
15 
16     if (0 == strcmp("tencent",as))
17     {
18         nR = nR + 1;
19         printf("2
");
20     }
21     
22     const char * sz = "tencnet";
23     if ("tencent" == sz)
24     {
25         nR = nR + 1;
26         printf("3
");
27     }
28     if (0 == strcmp("tencent", sz))
29     {
30         nR = nR + 1;
31         printf("4
");
32     }
33     if (sz == as)
34     {
35         nR = nR + 1;
36         printf("5");
37     }
38     
39     
40     printf("%d
",nR);
41     
42     
43     system("pause"); 
44     return 0;
45 }

 as 是一个字符串,sz只是一个指针。

原文地址:https://www.cnblogs.com/yyxayz/p/4481323.html