#include <iostream>
using namespace std;
int main()
{
int x = 1, y = 1;
cout << x-- && y--;
system("pause");
return 0;
}
为什么最后的会输出1
#include <iostream>
using namespace std;
int main()
{
int x = 1, y = 1;
cout << x-- && y--;
system("pause");
return 0;
}
为什么最后的会输出1
你这个x--先使用再自减 左边直接输出x的值了
比如x改为4输出就是4
#include <iostream>
using namespace std;
int main()
{
int x = 4, y = 1;
cout << x-- && y--;
return 0;
}
如果是 cout <<( x-- && y--);那么x--先使用再自减,左边是1,y--先使用再自减,右边也是1,最终与运算还是输出1