摘要: #include <iostream>using namespace std; // 阶乘之和--每次求和时都调用一次阶乘函数int factorial(int n){ if (n < 0) printf("值为负数,不能计算!!!\n"); else if (n == 1) return 1; e 阅读全文
posted @ 2020-01-07 16:44 TyranRex 阅读(595) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std; // n的阶乘 -- 1. 递归方法(必须要是返回值函数,而不能是void类型函数)int factorial1(int n){ if (n <= 0) printf("值为负数,不能判断!!!\n\n"); else 阅读全文
posted @ 2020-01-07 16:19 TyranRex 阅读(268) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std; // 3n+1 问题// 猜想:对于任意大于 1 的自然数 n,若 n 为奇数,则将n变为3*n+1;否则将n变为n的一半,计算运算过程次数void judge(int n){ int count = 0; while 阅读全文
posted @ 2020-01-07 15:37 TyranRex 阅读(258) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std; void complete_square(){ int n,i, high, low; for (i = 1;; i++) { n = i * i; if (n < 1000) continue; if (n > 999 阅读全文
posted @ 2020-01-07 15:08 TyranRex 阅读(369) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std; // 输入一个数是否是闰年void leap_year(int year){ if (year < 0) printf("输入为负,不能判别!!!\n\n"); else{ if (year % 400 == 0 || 阅读全文
posted @ 2020-01-07 14:32 TyranRex 阅读(138) 评论(0) 推荐(0) 编辑