上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 43 下一页
摘要: c/c++笔试面试题(3)2007-11-08 16:45903人阅读评论(0)收藏举报1.求下面函数的返回值(微软)int func(x){ int countx = 0; while(x) { countx ++; x = x&(x-1); } return countx;}假定x = 9999。 答案:8思路:将x转化为2进制,看含有的1的个数。2. 什么是“引用”?申明和使用“引用”要注意哪些问题?答:引用就是某个目标变量的“别名”(alias),对应用的操作与对变量直接操作效果完全相同。申明一个引用的时候,切记要对其进行初始化。引用声明完毕后,相当于目标变量名有两个名称,即该 阅读全文
posted @ 2012-11-28 17:57 可笑痴狂 阅读(541) 评论(0) 推荐(0)
摘要: c/c++笔试面试题(1)2007-11-08 16:42460人阅读评论(0)收藏举报1. 以下三条输出语句分别输出什么?[C易]char str1[] = "abc";char str2[] = "abc";const char str3[] = "abc";const char str4[] = "abc";const char* str5 = "abc";const char* str6 = "abc";cout << boolalpha << 阅读全文
posted @ 2012-11-28 17:56 可笑痴狂 阅读(487) 评论(0) 推荐(0)
摘要: c/c++笔试面试题(2)2007-11-08 16:43464人阅读评论(0)收藏举报int Strcmp(char *str1, char *str2){ int i=0; int b=0; while(str1[i]||str2[i]) { if(str1[i]>str2[i]) { b=1;break; } else if(str1[i]<str2[i]) { b=-1;break; } i++; } return b;}***************************************************************************** 阅读全文
posted @ 2012-11-28 17:56 可笑痴狂 阅读(297) 评论(0) 推荐(0)
摘要: cin、cin.get()、cin.getline()、getline()、gets()等函数的用法2007-11-17 22:23898人阅读评论(0)收藏举报【原创】cin、cin.get()、cin.getline()、getline()、gets()等函数的用法2007/10/27 22:51学C++的时候,这几个输入函数弄的有点迷糊;这里做个小结,为了自己复习,也希望对后来者能有所帮助,如果有差错的地方还请各位多多指教(本文所有程序均通过VC 6.0运行)转载请保留作者信息;1、cin1、cin.get()2、cin.getline()3、getline()4、gets()5、get 阅读全文
posted @ 2012-11-28 17:49 可笑痴狂 阅读(260) 评论(0) 推荐(0)
摘要: fibonacci数列(二)时间限制:1000ms | 内存限制:65535KB难度:3描述In the Fibonacci integer sequence,F0= 0,F1= 1, andFn=Fn− 1+Fn− 2forn≥ 2. For example, the first ten terms of the Fibonacci sequence are:0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …An alternative formula for the Fibonacci sequence is.Given an integern, your goal is 阅读全文
posted @ 2012-11-25 12:17 可笑痴狂 阅读(385) 评论(0) 推荐(0)
摘要: 三个水杯时间限制:1000ms | 内存限制:65535KB难度:4描述给出三个水杯,大小不一,并且只有最大的水杯的水是装满的,其余两个为空杯子。三个水杯之间相互倒水,并且水杯没有标识,只能根据给出的水杯体积来计算。现在要求你写出一个程序,使其输出使初始状态到达目标状态的最少次数。输入第一行一个整数N(0<N<50)表示N组测试数据接下来每组测试数据有两行,第一行给出三个整数V1 V2 V3 (V1>V2>V3 V1<100 V3>0)表示三个水杯的体积。第二行给出三个整数E1 E2 E3 (体积小于等于相应水杯体积)表示我们需要的最终状态输出每行输出相应测 阅读全文
posted @ 2012-11-25 12:06 可笑痴狂 阅读(2565) 评论(0) 推荐(0)
摘要: 迷宫寻宝(一)时间限制:1000ms | 内存限制:65535KB难度:4描述一个叫ACM的寻宝者找到了一个藏宝图,它根据藏宝图找到了一个迷宫,这是一个很特别的迷宫,迷宫里有N个编过号的门(N<=5),它们分别被编号为A,B,C,D,E.为了找到宝藏,ACM必须打开门,但是,开门之前必须在迷宫里找到这个打开这个门所需的所有钥匙(每个门都至少有一把钥匙),例如:现在A门有三把钥匙,ACM就必须找全三把钥匙才能打开A门。现在请你编写一个程序来告诉ACM,他能不能顺利的得到宝藏。输入输入可能会有多组测试数据(不超过10组)。每组测试数据的第一行包含了两个整数M,N(1<N,M<20 阅读全文
posted @ 2012-11-24 22:47 可笑痴狂 阅读(2259) 评论(0) 推荐(0)
摘要: JugsTime Limit:1000MSMemory Limit:65536KTotal Submissions:4076Accepted:2411Special JudgeDescriptionIn the movie "Die Hard 3", Bruce Willis and Samuel L. Jackson were confronted with the following puzzle. They were given a 3-gallon jug and a 5-gallon jug and were asked to fill the 5-gallon 阅读全文
posted @ 2012-11-20 20:45 可笑痴狂 阅读(3993) 评论(0) 推荐(0)
摘要: 转自:http://tieba.baidu.com/p/19883218911. freopen(“1.txt”,”r”,stdin);freopen(“1.txt”,”w”,stdout);2. memset(a,0,sizeof(a));数组定义int a[10] 为全局变量的话,其全部元素默认赋值为0;整型数据默认为0,字符串默认为空。3. #define max 0x0ffffff;#define min -0x0ffffff;4. 多组测试数据使用 while(n--){ 程序 }5. 一般用C语言节约空间,要用C++库函数或STL时才用C++;cout、cin和printf、sca 阅读全文
posted @ 2012-11-20 20:23 可笑痴狂 阅读(193) 评论(0) 推荐(0)
摘要: Function Run FunTime Limit:1000MSMemory Limit:10000KTotal Submissions:13517Accepted:7040DescriptionWe all love recursion! Don't we?Consider a three-parameter recursive function w(a, b, c):if a <= 0 or b <= 0 or c <= 0, then w(a, b, c) returns:1if a > 20 or b > 20 or c > 20, the 阅读全文
posted @ 2012-11-20 17:11 可笑痴狂 阅读(191) 评论(0) 推荐(0)
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 43 下一页