首页 > 其他 > 详细

腾讯实习生笔试的一道题

时间:2015-05-06 13:01:53      阅读:135      评论:0      收藏:0      [点我收藏+]
 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\n");
14     }
15 
16     if (0 == strcmp("tencent",as))
17     {
18         nR = nR + 1;
19         printf("2\n");
20     }
21     
22     const char * sz = "tencnet";
23     if ("tencent" == sz)
24     {
25         nR = nR + 1;
26         printf("3\n");
27     }
28     if (0 == strcmp("tencent", sz))
29     {
30         nR = nR + 1;
31         printf("4\n");
32     }
33     if (sz == as)
34     {
35         nR = nR + 1;
36         printf("5");
37     }
38     
39     
40     printf("%d\n",nR);
41     
42     
43     system("pause"); 
44     return 0;
45 }

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

腾讯实习生笔试的一道题

原文:http://www.cnblogs.com/yyxayz/p/4481323.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!