JSRUN 用代码说话
class Main {
	public static void main(String[] args) {
        //JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。
		System.out.println("Hello JSRUN!   \n\n         - from JAVA .");
        sumChar("xyxyXX");
	}

    public static void sumChar(string s) {
        if (null == s || s.length() == 0) {
            return;
        }
        int[] arr = new int[52];
        for(int i = 0; i <= s.length();i++) {
            char flag = s.charAt(i);
            if (flag >= 'a'){
                arr[flag-'a']++;
            } else {
                arr[flag-'A'+26]++;
            }
        }

        for(int j = 0; j < arr.length/2;j++) {
            print((j+'a').toString() + ":" + arr[j] + ";");
        }

        for( ;j < arr.length; j++ ) {
            print((j+'A').toString() + ":" + arr[j] + ";");
        }
    } 
}
yikes(dlililililidada) - 2020-09-29 0 人
sadawdafwfa
import java.util.Scanner;
import java.math.BigDecimal;

class Main {
	public static void main(String[] args) {
		
        while(true) {
            System.out.println("请输入数字,并在输入结束后按下回车键 :");
            Scanner in=new Scanner(System.in);
            String s = in.next() ;
            System.out.println("输入内容" + s + "是否为回文" + palNumber(s) + "\r\n\r\n");
        }
	}

    public static boolean palNumber(String s)  {

        if (s != null && s.length() > 1) {
            BigDecimal len = BigDecimal.valueOf(s.length());
            BigDecimal[] g = len.divideAndRemainder(BigDecimal.ONE.add(BigDecimal.ONE));
            
            int sid = g[0].intValue();
            int eid = g[0].intValue();
            if (g[1].compareTo(BigDecimal.ZERO) == 0) {
                sid = g[0].intValue();
            } else {
                eid = g[0].intValue() + 1;
            }
            String before = s.substring(0, sid);
            String after = s.substring(eid);

            StringBuffer sb=new StringBuffer(before);
            return sb.reverse().toString().equals(after);
        }  

        return false;
    }

}
zrbboo(博击天空) - 2020-09-29 0 人
判断内容是否为回文
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

class Main {

    public static void main(String[] args) {
        System.out.println("返回数组结果:\r\n\t第一位是最小公倍数\r\n\t第二位是最大公约数");
        BigDecimal[] b = calculateLcmAndHcf(12, 23, 24, 55, 70, 10, 11, 13, 19, 38, 34);
	    System.out.println(b[0]);
        System.out.println(b[1]);
	}

    /**
	 * 获取最小公倍数(LCM)和最大公约数(HCF)
	 * @param a 参数
	 * @return 最小公倍数、最大公约数
	 */
	public static BigDecimal[] calculateLcmAndHcf(Object... a) {
		List<BigDecimal> list = Stream.of(a).map(e -> new BigDecimal(e.toString())).collect(Collectors.toList());
		return calculateLcmAndHcf(list);
	}

	/**
	 * 获取最小公倍数(LCM)和最大公约数(HCF)
	 * @param a 参数
	 * @return 最小公倍数、最大公约数
	 */
	public static BigDecimal[] calculateLcmAndHcf(List<BigDecimal> list) {
		boolean anyMatch = list.stream().anyMatch(e -> e.compareTo(BigDecimal.ZERO) == 0);
		if (anyMatch) {
			return new BigDecimal[] {BigDecimal.ZERO, BigDecimal.ZERO};
		}
		BigDecimal[] a = list.toArray(new BigDecimal[] {});
		BigDecimal[] g = new BigDecimal[a.length];
		BigDecimal[] h = new BigDecimal[a.length];
		int b;
		int d = a.length;
		if (2 <= d) {
			// for (b = 0; b < d; b++) a[b] = rint(a[b]);
			BigDecimal e = null;
			BigDecimal f = null;
			for (b = 1; b < d; b++)
				if (1 == b) {
					e = get_gys(a[0], a[1]);
					f = get_gbs(a[0], a[1]);
				} else {
					e = get_gys(e, a[b]);
					f = get_gbs(f, a[b]);
				}
			for (b = 0; b < d; b++) {
				g[b] = f.divide(a[b], 0, BigDecimal.ROUND_DOWN);
				h[b] = a[b].divide(e, 0, BigDecimal.ROUND_DOWN);
			}
			return new BigDecimal[] { f, e };
		}
		return null;
	}

	private static BigDecimal get_gys(BigDecimal c, BigDecimal d) {
		if (compareNumber(c, d) < 0) {
			BigDecimal g = c;
			c = d;
			d = g;
		}
		for (;compareNumber(0, d) != 0;) {
			BigDecimal g = c.divideAndRemainder(d)[1];
			c = d;
			d = g;
		}
		return c;
	}

	private static BigDecimal get_gbs(BigDecimal c, BigDecimal d) {
		BigDecimal g = get_gys(c, d);
		return multiplyNumber(c, d).divide(g, 0, BigDecimal.ROUND_DOWN);
	}

    /**
	 * 比较大小
	 * 
	 * @param a 数值
	 * @param b 数值
	 * @return 大小
	 */
	public static int compareNumber(Object a, Object b) {
		if (a == null || b == null) {
			return 0;
		} else {
			return new BigDecimal(a.toString()).compareTo(new BigDecimal(b.toString()));
		}
	}

    /**
	 * 计算乘积
	 * 
	 * @param a 数值
	 * @param b 数值
	 * @return 两者乘积
	 */
	public static BigDecimal multiplyNumber(Object a, Object b) {
		if (a == null || b == null) {
			return null;
		} else {
			return new BigDecimal(a.toString()).multiply(new BigDecimal(b.toString()));
		}
	}

}
zrbboo(博击天空) - 2020-09-29 0 人
最大公约数、最小公倍数
public class Student {
	private String name;
	private int age;
	
	public Student() {
	}

	public Student(String name, int age) {
		this.name = name;
		this.age = age;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}
	
	
}
//==============================================================
import java.util.ArrayList;

public class Demo04ArrayListStudent {

	public static void main(String[] args) {
		
		//创建ArrayList对象list,泛型Student
		ArrayList<Student> list = new ArrayList<>();
		
		//创建4个学生对象
		Student one = new Student("jack", 18);
		Student two = new Student("tom", 19);
		Student three = new Student("kong", 20);
		Student four = new Student("rose", 21);
		
		//将4个学生对象添加到集合中
		list.add(one);
		list.add(two);
		list.add(three);
		list.add(four);
		
		//遍历集合
		for (int i = 0; i < list.size(); i++) {
			Student stu = list.get(i);
			System.out.println("姓名:" + stu.getName() + ",年龄:" + stu.getAge());
		}
	}

}
1372013532(Azezit) - 2020-09-28 0 人
自定义4个学生对象,添加到集合,并遍历。
package demo03;

import java.util.ArrayList;
import java.util.Random;

public class Demo03ArrayListRandom {

	public static void main(String[] args) {
		
		//创建ArrayList对象list
		ArrayList<Integer> list = new ArrayList<>();
		//创建Random对象r
		Random r =  new Random();
		
		//循环产生6个随机数
		for (int i = 0; i < 6; i++) {
			int num = r.nextInt(33) + 1;
			//添加到集合当中
			list.add(num);
		}
		//遍历集合
		for (int i = 0; i < list.size(); i++) {
			System.out.println(list.get(i));
		}
	}

}
1372013532(Azezit) - 2020-09-28 0 人
生成6个1~33之间的随机整数,添加到集合,并遍历...
import java.util.*;
public class Two2018 {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int []shuzu=new int [100];
		int flag=1;
		int i,j;
		for(i=0;shuzu[i]!=-1;i++){
		    shuzu[i]=in.nextInt();
		    String ss=Integer.toString(shuzu[i]);
		    int len=ss.length();
		    for(j=0;j<len/2;j++){
		        if(ss.charAt(j)!=ss.charAt(len-j-1))
		            {
		                flag=0;
		                break;
		            }
		    }
		    if(flag==1){
		        System.out.print(shuzu[i]+" ");
		    }else{
		        flag=1;
		    }
		}
		
	}
}
mr.guo(踏浪独行。) - 2020-09-28 0 人
2018年第二题回文殊。
没有了
1/67 下一页