求斐波那契数列前n项(循环结构)
摘要:#include <iostream> using namespace std; void Fibonacci(int n) { unsigned int a = 1, b = 1; cout << a << '\t' << b << '\t'; for (int t = 3; t <= n; ++
阅读全文
posted @
2021-09-15 21:57
学群
阅读(487)
推荐(0)
递归法求斐波那契数列
摘要:#include <iostream> using namespace std; int Fibonacci(int n) { if (n == 1 || n == 2) return 1; else return Fibonacci(n - 1) + Fibonacci(n - 2); } int
阅读全文
posted @
2021-09-15 21:28
学群
阅读(555)
推荐(0)
求小于正整数n的质数改良
摘要:#include <iostream> #include <iomanip> using namespace std; void GetPrimenumber() { cout<<"求小于正整数n的素数,请输入正整数:"; int n; cin >> n; int c = 0; int h = 0;
阅读全文
posted @
2021-09-15 20:24
学群
阅读(55)
推荐(0)