宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取
//输出100的阶乘 使用字符串存入阶乘的结果 然后每一位一次计算结果。 #include<iostream> #include<string> using namespace std; int main) { string a = "1"; for int i = 1; i < 100; i++) { int y = 0; for int j = 0; j < a.length); j++) { int x = int)a[j] - '0'); x = x*i; x = x + y; y = x / 10; x = x % 10; a[j] = char)x + '0'); } while y) { a = a + char)y % 10)+'0'); y = y / 10; } for int k = a.length) - 1; k >= 0; k--) { cout << a[k]; } cout << endl; } return 0; }