几道c笔试题(参考答案).doc

  1. 1、本文档共12页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
几道c笔试题(参考答案)

1. What is displayed when f() is called given the code: class Number { public: string type; Number(): type(“void”) { } explicit Number(short) : type(“short”) { } Number(int) : type(“int”) { } }; void Show(const Number n) { cout n.type; } void f() { short s = 42; Show(s); } a) void b) short c) int d) None of the above 2. Which is the correct output for the following code double dArray[2] = {4, 8}, *p, *q; p = dArray[0]; q = p + 1; cout q – p endl; cout (int)q – (int)p endl; a) 1 and 8 b) 8 and 4 c) 4 and 8 d) 8 and 1 第一个选C; 虽然传入的是short类型,但是short类型的构造函数被生命被explicit,也就是只能显示类型转换,不能使用隐式类型转换。 第二个选A; 第一个是指针加减,按照的是指向地址类型的加减,只跟类型位置有关,q和p指向的数据类型以实际数据类型来算差一个位置,因此是1。而第二个加减是实际指针值得加减,在内存中一个double类型占据8个字节,因此是8 c/c++某大公司的两道笔试题(含参考答案 ) 1.一群人围成一圈,123的报数,报3者出列,求最后一个人。 2.利用链表实现将两个有序队列A和B合并到有序队列H中,不准增加其他空间。 请提供全一点的程序 第一题: // kickout.cpp : Defines the entry point for the console application. // #include “stdafx.h” #include “malloc.h” #include “stdio.h” int main() { int m,n; int kickouts = 0; int *p = NULL; int i ,j; i=j=0; printf(“Please input m,n:”); scanf(“%d,%d”,m,n); while(n1) { printf(n doent less 0 , retry n:); scanf(%d,n); } p=(int*)malloc(m*sizeof(int)); for(i=0;i p[i]=1; i = 0; while(1) { i = i%m; if(p[i++]) j++; if(j == n) { p[i-1]=0; j = 0; kickouts++; } if(kickouts == m-1) break; } for(i = 0;i if(p[i]) printf(%d\n,i+1); return 0; } 2、升序还是降序? 以升序为例: while(a != NULL b!= NULL) { if (a-data b-data) { h-data = a-data; a = a-next; } else if (a-data == b-data) { h-data = a-data; a = a-next; b = b-next; } else { h-data = b-data; b = b-next } h = h-next; } if (a == NULL) { while (b != NULL) { h-data = b-data; h = h-next; b = b-next; } } else { while(a != NULL) { h-data = a-next; h = h-next; a = a-next; } } C语言面试题 1。编写一个 C 函数,该函数在一个字符串中找到可能的最长的子字符串,且该字符串是由同一字符组成的。 char * search(char *cpSource, char ch) { char *cpTemp=NULL, *cpDest=NULL; int iTemp, iCount=0; while(*cpSource) { if(*cpSource == ch) { iTemp = 0; cpTemp = cpSource; while(*cpSource == ch) ++iTemp, ++cpSource;

文档评论(0)

xll805 + 关注
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档