2013.02.13——笔记

  博客地址:http://www.cnblogs.com/zengjianrong/archive/2013/02/23/2923886.html 

程序员面试宝典

1.  5.1-2:下列代码输出为:4  10 

#include "stdafx.h"
using namespace std;

int Vac=3;
int _tmain(int argc, _TCHAR* argv[])
{
	int Vac=10;
	::Vac++;
	cout<<::Vac<<endl;
	cout<<Vac<<endl;
	system("pause");
	return 0;
}

2.  5.2-3:x=x+1,x+=1,x++,那个效率高?

3.  5.4-1:c语言中整数自动转换原则:表达式中有无符号数和有符号数时,所有操作数自动转换为无符号数,故如下程序输出为0;

 1 #include "stdafx.h"
 2 using namespace std;
 3 
 4 int _tmain(int argc, _TCHAR* argv[])
 5 {
 6     unsigned int a=6;
 7     int b=-10;
 8     int c;
 9     (a+b>0)?(c=0):(c=1);
10     cout<<c<<endl;    
11     system("pause");
12     return 0;
13 }
原文地址:https://www.cnblogs.com/zengjianrong/p/2923886.html