这是Java实验编程的一道题,我知道对于学软件的来说很简单但是对于毫不相关的专业……你们懂得……求大家帮助……急……在线等,感激不尽
请问可以只用循环和数组字符串章节的知识咩……太复杂看不懂……我们只学了java的前五章……会露馅的……(抱大腿)
追答public class arrayfile {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
// Map map = new HashMap();
int [] m = new int[10];
// for (int i = 0; i < 10; i++) {
// map.put(i, 0);
// }
String s = null;
while (true) {
System.out.println("请输入:");
s = sc.nextLine();
if (Pattern.matches("^[0-9]*$", s)) {
break;
}
}
char[] a =s.toCharArray();
for (char cc:a) {
Integer in = Integer.parseInt(cc+"");
m[in]=m[in]+1;
System.out.println(in);
}
for(int i=0;i<10;i++){
System.out.println(i+"出现了"+m[i]+"次");
}
}
}
刚试了一下 运行不ok哦
追答什么啊
本回答被提问者和网友采纳