Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
3a237a37aa | |||
541d50655c |
19
class/e_de_jin_se_zhi.cpp
Normal file
19
class/e_de_jin_se_zhi.cpp
Normal 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;
|
||||
}
|
29
class/fen_zi_xue_lie_qiu_he.cpp
Normal file
29
class/fen_zi_xue_lie_qiu_he.cpp
Normal 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;
|
||||
}
|
25
class/zui_da_gong_yue_shu.cpp
Normal file
25
class/zui_da_gong_yue_shu.cpp
Normal 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
13
old_homework/3721.cpp
Normal 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
25
test.cpp
Normal 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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user