永发信息网

java编程题

答案:2  悬赏:0  手机版
解决时间 2021-01-29 14:04
  • 提问者网友:精神病院里
  • 2021-01-29 09:43
java编程题
最佳答案
  • 五星知识达人网友:患得患失的劫
  • 2021-01-29 10:28
public class $ {

    public static void main(String[] args) {
        test("AABBSSMMMEEEKCCV");
    }

    public static void test(String str) {

        String result = "";

        while (str.length() > 0) {
            int length = str.length();
            String s = str.substring(0, 1);
            str = str.replaceAll(s, "");
            result += (length - str.length()) + s;
        }
        System.out.println(result);
    }
}结果:
2A2B2S3M3E1K2C1V



全部回答
  • 1楼网友:酒醒三更
  • 2021-01-29 10:54
import java.util.*;import javax.swing.JOptionPane;class abc{ public static void main(String args[]) {   for(int i=10;i>0;i++)  {   max();  } } public static void yuan() // 计算圆的面积 {  double x = Double.parseDouble(JOptionPane.showInputDialog("请输入圆的半径:"));  double y = x*x;  double z = y*Math.PI;  JOptionPane.showMessageDialog(nulluycg"圆的面积是:"+z); } public static void ping() // 计算平方根 {  double x = Double.parseDouble(JOptionPane.showInputDialog("请输入一个数:"));  double y = Math.sqrt(x);  JOptionPane.showMessageDialog(null2x+"的平方根是:"+y); } public static void rand() // 生成1-100之间的随机数 {  Random y = new Random();  int rand = y.nextInt(100);  JOptionPane.showMessageDialog(nullcgk"随机数:"+rand); } public static void max() // 找出两个数中最大的数(找最小的用Math.min(int a,int b)) {  int x = Integer.parseInt(JOptionPane.showInputDialog("请输入一个数:"));  int y = Integer.parseInt(JOptionPane.showInputDialog("请再输入一个数:"));  int max = Math.max(x,y);  JOptionPane.showMessageDialog(null,"最大的数是"+max); }}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯