#include <iostream> #include <string> #include <stdio.h> using namespace std; //参数的调用顺序是从右向左 int test1() { cout << "test1" << endl; return 1; } int test2() { cout << "test2" << endl; return 2; } int main() { int i = 3; //先执行右边的i++,再执行左边的i 但是显示的时候,按"i = %d,i++ = %d\n"的顺序显示 printf("i = %d,i++ = %d\n",i,i++); //显示: i = 4,i++ = 3 i = 3; printf("i = %d,i++ = %d,i++ = %d\n",i,i++,i++); //显示: i = 5,i++ = 4,i++ = 5 //先执行右边的test2(),再执行左边的test1() 但是显示的时候,按"%d,%d\n"的顺序显示 printf("%d,%d\n",test1(),test2()); //先执行右边的test2(),再执行左边的test1() 但是显示的时候,按顺序显示 cout << test1() << " " << test2() << endl; return 0; }
执行程序: