第三次实验课代码
添加NumberCounter和EncryptDemo
This commit is contained in:
11
C03 ControlFlow/C03 ControlFlow.iml
Normal file
11
C03 ControlFlow/C03 ControlFlow.iml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
17
C03 ControlFlow/src/NumberCounter.java
Normal file
17
C03 ControlFlow/src/NumberCounter.java
Normal file
@@ -0,0 +1,17 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class NumberCounter {
|
||||
public static void main(String[] args) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
long num = sc.nextLong();
|
||||
int[] hash = new int[10];
|
||||
while(num>0){
|
||||
hash[(int)(num%10)]++;
|
||||
num/=10;
|
||||
}
|
||||
|
||||
for(int i : hash)
|
||||
System.out.print(i+" ");
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user