题解 | #阶乘#
阶乘
https://www.nowcoder.com/practice/e58c8a55162d49c48115bdfa5da7da56
#include "bits/stdc++.h" using namespace std; int jiechen(int n) { int result = 1; for (int i = 1; i <= n; ++i) { result = result * i; } return result; } int main() { int n; int y1, y2 = 0; while (cin >> n) { for (int i = 1; i <= n; i += 2) { y1 += jiechen(i); } for (int i = 2; i <= n; i += 2) { y2 += jiechen(i); } printf("%d %d", y1, y2); } }