2011年8月17日

一道很有意思的面试题

摘要: 求较小的值,不能用 比较运算符 if-else ?: while for 内嵌汇编 递归 第三方函数int Min(int a, int b){ //write code here}我给的回复是#include <stdio.h>// 要求写的函数int Min(int a, int b){ return (&b)[(a-b)>>31];}// 测试代码int main(void){ int a = 111; int b = 114; printf("The smaller one of %d and %d is %d\n", a, b, M 阅读全文

posted @ 2011-08-17 03:51 karying 阅读(290) 评论(0) 推荐(1) 编辑

cerr和cout的区分

摘要: cerr与cout的主要区分就是,cout输出的信息可以重定向,而cerr只能输出到标准输出(显示器)上。 例如下面程序编译后生成test.exe // test.cpp #include <iostream.h> int main() { cout << "hello world---cout" << endl ; cerr << "hello world---cerr" << endl ; return 0; }在命令行模式下键入下面的命令: test >>cout.txt 运行 阅读全文

posted @ 2011-08-17 03:31 karying 阅读(321) 评论(0) 推荐(0) 编辑

导航