++运算符问题
++运算符在前和在后我都懂,但下面这几个式子还是很费解,求解释
#include <iostream.h>
int fun(int x, int y)
{
return x*y;
}
void main()
{
int k=5;
cout<<fun(++k,++k)<<endl;
k=5;
cout<<fun(k++,k++)<<endl;
k=5;
cout<<fun(++k,k++)<<endl;
k=5;
cout<<fun(k++,++k)<<endl;
k=5;
cout<<(++k)*(++k)<<endl;
k=5;
cout<<(k++)*(k++)<<endl;
k=5;
cout<<(++k)*(k++)<<endl;
k=5;
cout<<(k++)*(++k)<<endl;
}
答案依次是: 42 25 30 36 49 25 36 36