主函数里面的n 执行f(1) 执行f(2)有先后顺序吗 为什么

#include "stdio.h"
int f(int x)

static int s=0;
int i;
for(i=l;i<=x;i++)
s=s+i;
return s;

void main()

int n;
n=f(I)+f(2);
printf("%dn" ,n);

最终 n 的结果为5。
因为在函数 f()中 s 为静态变量,所以在调用 f(1) 时,return s 返回 1 ,同时 s 保持为 1。当调用 f(2) 时,i=1 ,s = s + i = 1 + 1 = 2, i = 2 时 ,s = s + i = 2 + 2 =4, return s 返回值为 4 .
所以在主函数里:n = f(1) + f(2) = 1 +4 = 5.

+ 从左到右结合