-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString_3.java
More file actions
49 lines (41 loc) · 1.01 KB
/
Copy pathString_3.java
File metadata and controls
49 lines (41 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package HuaweiCoding;
import java.util.Scanner;
public class String_3 {
public static String cutDown(String str) {
StringBuilder sb=new StringBuilder();
if(str.length()==8) {
sb.append(str).append("\n");
}
if(str.length()<8) {
int counts=8-str.length();
sb.append(str);
for(int i=0;i<counts;i++) {
sb.append("0");
}
sb.append("\n");
}
if(str.length()>8) {
int counts=str.length()/8;
int index=0;
for(int i=0;i<counts;i++) {
sb.append(str.substring(index, index+8)).append("\n");
index+=8;
}
int temp=index+8-str.length();
sb.append(str.substring(index));
for(int i=0;i<temp;i++) {
sb.append("0");
}
sb.append("\n");
}
return sb.toString();
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String nextLine = sc.nextLine();
String nextLine2 = sc.nextLine();
String sb= cutDown(nextLine);
sb+=cutDown(nextLine2);
System.out.println(sb.toString());
}
}