帮我编个程序!用C++。

来源:百度知道 编辑:UC知道 时间:2024/05/13 23:10:26
1+2!+3!+........+12!

修正一楼的

#include <iostream>
using namespace std;

void main() {
int n = 12, s = 0, x = 1;
for(int i = 1; i <= n; i++)
s += x *= i;
cout << " s = "<< s << endl;

cin.ignore();
}

s = 522956313
Press any key to continue

main() {
int n = 12, s = 0, x = 1;
for(int i = 1; i <= n; i++)
s += x *= i;
cout<<" s = "<<s<<endl;
}