Compare commits

...

2 Commits
CPP ... master

Author SHA1 Message Date
3a237a37aa 更新 README.md 2025-02-28 21:52:04 +08:00
541d50655c ? 2025-02-03 11:23:49 +08:00
6 changed files with 112 additions and 3 deletions

View File

@ -1,3 +1 @@
**_本仓库为私人仓库_** **_本仓库为私人仓库_**
**b667c019058732967262412c7aee4475**

19
class/e_de_jin_se_zhi.cpp Normal file
View File

@ -0,0 +1,19 @@
#include<iostream>
#include<iomanip>
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;
}

View File

@ -0,0 +1,29 @@
//分子序列求和
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int n;
double a=2,b=1,c,d;
cin >>n;
if (n > 100)
{
cout <<"输入的数字太大了!"<<endl;
return 1;
}
double sum=0;
for (int i = 1; i <= n; i++)
{
sum += a/b;
c = a;
d = b;
a = a+d;
b = c;
}
cout <<fixed<<setprecision(2)<<sum<<endl;
return 0;
}

View File

@ -0,0 +1,25 @@
#include <iostream>
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;
}

13
old_homework/3721.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <iostream>
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;
}

25
test.cpp Normal file
View File

@ -0,0 +1,25 @@
#include <iostream>
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;
}