//i++面试题1.cpp
//中国台湾某著名杀毒软件公司2005年10月面试题
int i=3,j=4;
i?i++:++j;
printf("%d %d/n",i,j);
//A. 3 3 B. 4 4 C.3 4 D.4 3
//答案B
//i++面试题2.cpp
//中国某著名计算机金融软公司2005年面试题
int x=1,j=2;
int k=i+++j;
cout<<k<<endl;
//A. 2 B. 3 4 C.4 D. 5
//答案B
//(i++)+j
//i++面试题3.cpp
//x=x+1,x+=1,x++,哪个效率最高?为什么?
//解析:
//x=x+1最低,因为它的执行过程如下:
//(1)读取右x的地址。
//(2)x+1
//(3)读取左x的地址
//(4)将右值传给左边的x(编译器并不认为左右x的地址相同)
//x+=1;其次,其执行过程如下:
//(1)读取右x的地址
//(2)x+1
//(3) 将得到的值传给x(音问x的地址已经读出)
//x++;效率最高.其执行过程如下:
//(1)读取右x的地址
//(2)x自增1
//答案:x++效率最高。
//i++面试题4.cpp
//What will be the output of the following C code?[中国台湾某著名CPU生产公司2005年面试题]
#include<stdio.h>
#define product(x) (x*x)
int main()
{
int i=3,j,k;
j=product(i++);
k=product(++i);
printf("j=%d,k=%d",j,k);
return 0;
}
//9 49
//product(i++)=i++*i++;
//i++面试题5.cpp
//中国某著名综合软件公司2005年面试题
//If there are "int a=5,b=3;", the valule of a and b are ? and ?
//after execute "!a&&b++;".
//A. 5, 3 B.0,1 C.0,3 D.5,4