//static循环问题
#include<stdio.h> int sum(int a) { int c = 0; static int b = 3;//static修饰之后,只有第一次执行int b=3,之后该语句无效 c += 1; b += 2; return(a + b + c); } int main() { int i; int a = 2; for (i = 0; i < 5; i++) { printf("%d\n", sum(a)); } }
//static循环问题
#include<stdio.h> int sum(int a) { int c = 0; static int b = 3;//static修饰之后,只有第一次执行int b=3,之后该语句无效 c += 1; b += 2; return(a + b + c); } int main() { int i; int a = 2; for (i = 0; i < 5; i++) { printf("%d\n", sum(a)); } }