Compare commits
2 Commits
8fc5db6fe0
...
1986bbbe3e
| Author | SHA1 | Date | |
|---|---|---|---|
| 1986bbbe3e | |||
| 84a699fc37 |
@@ -5,7 +5,7 @@ public class NumberProcessor {
|
|||||||
Scanner sc = new Scanner(System.in);
|
Scanner sc = new Scanner(System.in);
|
||||||
System.out.println("请输入一个三位或四位整数");
|
System.out.println("请输入一个三位或四位整数");
|
||||||
int number = sc.nextInt();
|
int number = sc.nextInt();
|
||||||
if(number%100>0 && number%100<10){
|
if(number%100>0 && number%100<99){
|
||||||
while(number>0){
|
while(number>0){
|
||||||
System.out.println(number%10);
|
System.out.println(number%10);
|
||||||
number = number / 10;
|
number = number / 10;
|
||||||
|
|||||||
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>
|
||||||
26
C03 ControlFlow/src/EncryptDemo.java
Normal file
26
C03 ControlFlow/src/EncryptDemo.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import java.util.Scanner;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class EncryptDemo {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
String str = sc.nextLine();
|
||||||
|
|
||||||
|
byte key = sc.nextByte();
|
||||||
|
char[] enc= new char[str.length()];
|
||||||
|
for(int i=0;i<str.length();i++)
|
||||||
|
enc[i] =(char)(str.charAt(i) ^ key);
|
||||||
|
|
||||||
|
// for(char c:enc)
|
||||||
|
// System.out.print(c);
|
||||||
|
System.out.println(Arrays.toString(enc));
|
||||||
|
|
||||||
|
char[] dec= new char[enc.length];
|
||||||
|
for(int i=0;i<str.length();i++)
|
||||||
|
dec[i] =(char)(enc[i] ^ key);
|
||||||
|
|
||||||
|
// for(char c:dec)
|
||||||
|
// System.out.print(c);
|
||||||
|
System.out.println(Arrays.toString(dec));
|
||||||
|
}
|
||||||
|
}
|
||||||
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