编程练习随笔
文章平均质量分 52
廿士
这个作者很懒,什么都没留下…
展开
-
例题备忘簿
文章目录求最大公约数 求最大公约数 辗转相除法\更相减损术 使用条件(三元)运算符, public class Main { public static void main(String[] args) { int a = Integer.parseInt(args[0]); int b = Integer.parseInt(args[1]); while( a != b ){ a=(a>b) ? a-b : a;原创 2022-04-14 16:19:42 · 75 阅读 · 0 评论 -
编程练习随笔----寻找峰值
文章目录题目描述代码分析 题目描述 山峰元素是指其值大于或等于左右相邻值的元素。 给定一个输入数组nums,任意两个相邻元素值不相等,数组可能包含多个山峰。 找到索引最大的那个山峰元素并返回其索引。 假设 nums[-1] = nums[n] = -∞。 https://www.nowcoder.com/practice/1af528f68adc4c20bf5d1456eddb080a?tpId=196&tqId=37165&rp=1&ru=%2Fta%2Fjob-code-tot原创 2021-05-05 17:05:53 · 284 阅读 · 0 评论 -
编程练习随笔----斐波那契数列
文章目录题目描述代码分析 题目描述 斐波那契数列挺经典的,OJ可以点击链接提交查看(牛客网) 代码分析 /** * * @param n int整型 * @return int整型 */ int Fibonacci(int n ) { // write code here int ans = 0;//存放最终结果 int Front[2] = {0,1};//递归公式前2项 if( n < 2 ) { switch (n)原创 2021-04-28 17:42:54 · 75 阅读 · 0 评论