摘要: 算法竞赛更新第一帖! 阅读全文
posted @ 2019-11-19 23:12 TyranRex 阅读(492) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std; // 100-999的水仙花数// 水仙花数:M=A*A*A+B*B*A+C*C*Cvoid Daffodil(){ int m=0,n = 0; printf("100-999的所有水仙花数如下:\n"); for ( 阅读全文
posted @ 2020-01-11 23:18 TyranRex 阅读(339) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <stdio.h>#define INF 100000000000using namespace std; // 文件输入输出小应用int main(){ FILE* fin, * fout;// 定义两个文件类型指针 fin = fopen( 阅读全文
posted @ 2020-01-11 22:53 TyranRex 阅读(370) 评论(0) 推荐(0) 编辑
摘要: #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 阅读(592) 评论(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 阅读(267) 评论(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 阅读(256) 评论(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) 编辑
摘要: #include <iostream> using namespace std;void judge_triangle(int L, int m, int s); // 若函数调用顺序和函数的编写不一致,需要声明函数// 三数排序--从大到小void trangle(int x, int y, in 阅读全文
posted @ 2020-01-06 19:05 TyranRex 阅读(848) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <math.h>using namespace std; // 输出一个数的绝对值--自定义或者使用math.h中的abs()函数void abs_value(float n){ if (n < 0) printf("该数%f是负数,输出它的相 阅读全文
posted @ 2020-01-06 17:33 TyranRex 阅读(684) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>// 常量可用静态常量定义,也可使用宏定义#define sum 300#define dis 0.85#define price 95using namespace std; void discount(int num){ if (num * price <= 阅读全文
posted @ 2020-01-06 17:20 TyranRex 阅读(211) 评论(0) 推荐(0) 编辑