有过C++开发经验的人会发现,我们可以将0作为false,非零作为true。一个函数即使是bool类型的,但是我们还是可以返回int类型的,并且自动将0转换成false,非零转换成true。代码实例如下:
#include
#include
using namespace std;
bool fun()//函数返回类型是bool,但是我们在函数中可以返回int类型。
{
return ...
分类:
编程语言 时间:
2015-04-16 23:50:32
阅读次数:
287
#include
using namespace std;
class A
{
public:
A()
{
cout<<"this is construction"<<endl;
}
virtual ~A()
{
cout<<"this is destruction"<<endl;
}
};
A fun()
{
A a;
return a;
}
int main()
{
...
分类:
其他好文 时间:
2015-04-16 10:18:30
阅读次数:
125
#include #include#includeint main() { int i=0,j=0,n;char str[10];char strsd[100];char cmd[20][10]; char fun[20][50]; ...
分类:
其他好文 时间:
2015-04-15 21:23:07
阅读次数:
119
转载自:http://www.w3cplus.com/css/fun-line-height.htmlCSS中的line-hight属性是用来控制文本行之间的空隙的。它一般情况下没有单位的设定(如:line-height:1.4;)所以这是一个按字体尺寸的比例来计算。这对印刷版来说是一个很重要的属性...
分类:
其他好文 时间:
2015-04-15 11:15:21
阅读次数:
160
最近见群里有一道关于面试的试题,考察的关于全局变量和局部变量的基础知识:
fun foo(){
var a = b = 0;}
让选择a和b的值分别为多少,或许不仔细看,我们很可能把a和b都当成了局部变量,值为0,其实a是局部变量,b是全局变量,这主要是由于从右至左的操作符优先级,跟我们平时在的css选择器在浏览器中解析的优先级别一样,优先级别较高的是表达式b=0,此时b未经声明,表达式的返回...
分类:
编程语言 时间:
2015-04-14 23:22:30
阅读次数:
148
观看几个程序片段,分析行为
1、
public static boolean fun(){
try{
return false;
}finally{
return true;
}
}
System.out.println(fun());
2、
public static boolean fun(){
try{
return false;
}fina...
分类:
其他好文 时间:
2015-04-14 16:43:54
阅读次数:
106
这个代码写了两天,从没思路到有思路,还好最终搞定了~不过这个进程数必须为2^n个。
先贴一个运行截图:
-module(exe4).
-export([start/5]).start(F,X1,X2,Num,Cores)
->spawn(fun()->parent_proces(F,X1,X2,Num,Cores) end),
io:format("").parent_proce...
分类:
其他好文 时间:
2015-04-14 00:47:01
阅读次数:
232
Fun House
Time Limit: 1000MS Memory limit: 65536K
题目描述
American Carnival Makers Inc. (ACM) has a long history of designing rides and attractions. One of their more popular attract...
分类:
其他好文 时间:
2015-04-13 11:02:32
阅读次数:
149
内部函数 //static 类型名 函数名 (参数表)// 例如:static int fun(int a,int b)//表示fun是一个内部函数,不能憋其他文件调用//内部函数又称静态函数外部函数//如果在定义函数时,在函数首部的最左端加关键字extern//则此函数时外部函数,可供其他文件调用...
分类:
其他好文 时间:
2015-04-12 22:16:46
阅读次数:
109
Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number con...
分类:
其他好文 时间:
2015-04-12 16:16:59
阅读次数:
128