//
#include <iostream>
using namespace std;
int main()
{
int i, s = 0;
extern int fact(int x);
for (int i = 2; i <= 6; i = i + 2)
s += fact(i);
cout << "s=" << s << endl;
}
extern int fact(int x)
{
int i, t = 1;
if (x == 0) return (1);
for (int i = 1; i <= x; i++)
t *= i;
return(t);
}
程序应该是求2到6的偶数阶乘和:2!+4!+6!
main()函数的for循环就是遍历2到6所有的偶数,也就是2,4,6
i从2开始,i=i+2,每次加2,变为4,再变为6