diff --git a/class/e_de_jin_se_zhi.cpp b/class/e_de_jin_se_zhi.cpp new file mode 100644 index 0000000..fe37224 --- /dev/null +++ b/class/e_de_jin_se_zhi.cpp @@ -0,0 +1,19 @@ +#include +#include + +using namespace std; + +int main(){ + double e = 1.0; + double factorial = 1.0; + + for (int i = 1; i <= 20; i++) + { + factorial *= i; + e += 1.0 / factorial; + } + + cout << fixed << setprecision(3) << e << endl; + + return 0; +} \ No newline at end of file diff --git a/class/fen_zi_xue_lie_qiu_he.cpp b/class/fen_zi_xue_lie_qiu_he.cpp new file mode 100644 index 0000000..bcaec79 --- /dev/null +++ b/class/fen_zi_xue_lie_qiu_he.cpp @@ -0,0 +1,29 @@ +//分子序列求和 +#include +#include + +using namespace std; + +int main(){ + int n; + double a=2,b=1,c,d; + cin >>n; + + if (n > 100) + { + cout <<"输入的数字太大了!"< +using namespace std; + +int main(){ + int n,m,x; + + cout << "请输入两个数:"; + cin >> n >> m; + + if (m>n) + { + x = n; + }else + { + x = m; + } + + while ( n%x!=0 || m%x!=0) + { + x--; + } + + cout << "最大公约数为:" << x << endl; + return 0; +} \ No newline at end of file diff --git a/old_homework/3721.cpp b/old_homework/3721.cpp new file mode 100644 index 0000000..3d1700f --- /dev/null +++ b/old_homework/3721.cpp @@ -0,0 +1,13 @@ +#include +using namespace std; + +int main() { + // 遍历1到200的所有数 + for (int i = 1; i <= 200; i++) { + // 判断该数是否满足"3721"数的条件 + if (i % 3 == 2 && i % 7 == 1) { + cout << i << " "; // 输出满足条件的数 + } + } + return 0; +} diff --git a/test.cpp b/test.cpp new file mode 100644 index 0000000..76faf6e --- /dev/null +++ b/test.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +// 函数:计算最大公约数 +int gcd(int a, int b) { + while (b != 0) { + int temp = b; + b = a % b; + a = temp; + } + return a; +} + +// 函数:计算最小公倍数 +int lcm(int a, int b) { + return (a / gcd(a, b)) * b; +} + +int main() { + int M, N; + cin >> M >> N; + cout << lcm(M, N) << endl; + return 0; +} \ No newline at end of file