随笔分类 - 算法题
摘要:根据题目意思先来缕清一下思路: 第一年 初始值为 1 (也就是刚开始一头母牛) 第二年 2(也就是刚开始一头母牛+一头小母牛) ) 第三年 3(也就是刚开始一头母牛+两头小母牛) ) 第四年年 4(也就是刚开始一头母牛+三头小母牛) ) 第五年 6(也就是刚开始一头母牛+加上四头小母牛+由于第二年生
阅读全文
摘要:package Demo3; import java.util.Scanner; public class D2 { /** * 90~100为A; * * 80~89为B; * * 70~79为C; * * 60~69为D; * * 0~59为E; * */ public static void
阅读全文
摘要:import java.util.Scanner; public class D1 { public static void main(String[] args) { /** * 你的任务就是计算A + B,然后输出结果 */ //Scanner类是Java中用于解析输入的工具类,它提供了一系列方
阅读全文
摘要:public static void main(String[] args) { // 判断数组中找元素最大值 int[] Array = {23,12,45,24,10,60,30,2,1}; System.out.println(maxValue(Array)); } public static
阅读全文
摘要:Random random = new Random(); int[] number = new int[10]; for (int j = 0; j < 10; j++) {#指定了随机数范围0~100; number[j] = random.nextInt(100); } int sum = 0
阅读全文
摘要:Random random = new Random();int result = 1; int i= 1;while (i<=5){ result*=i; i++;}System.out.println(result);
阅读全文
摘要:思路: 比如 n =1234; 那么如何获取4,应该 n%10; 那么如何获取3,获取3之前应该删除4,所以n/10; //40 +3 =43//43*10 = 430>430+2(432)>432*10(4320)+1r=0 怎么获取40:r *10 +d 看代码: 1 public class
阅读全文
摘要:思路: 1 public class test { 2 public static void main(String[] args) { 3 int number =1234; 4 System.out.println(number%10); 5 System.out.println(number/
阅读全文

浙公网安备 33010602011771号