質問編集履歴
3
sss
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,34 +1,50 @@
|
|
1
|
-
```Java
|
1
|
+
```Java 修正
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
public class addNo {
|
6
|
+
|
7
|
+
|
2
8
|
|
3
9
|
public String addNo(String inData){
|
4
10
|
|
5
|
-
|
11
|
+
char[] outData = inData.toCharArray();
|
6
12
|
|
7
|
-
|
13
|
+
int[] mul = {1,3,7,9,7,3,1,3,9,7,1};
|
8
14
|
|
9
|
-
|
15
|
+
int n = Math.min(outData.length,9);
|
10
16
|
|
11
|
-
|
17
|
+
for(int i = 0; i < n; i++)
|
12
18
|
|
13
|
-
|
19
|
+
outData[i] = (char)((outData[i] -'0')* mul[i] % 10+ '0');
|
14
20
|
|
15
|
-
|
21
|
+
String outData01 = outData.toString();
|
16
22
|
|
23
|
+
int total = 0;
|
24
|
+
|
17
|
-
|
25
|
+
total += n;
|
18
26
|
|
19
27
|
|
20
28
|
|
21
|
-
return new String(outData
|
29
|
+
return new String(outData01);
|
30
|
+
|
31
|
+
}
|
32
|
+
|
33
|
+
|
22
34
|
|
23
35
|
}
|
24
36
|
|
25
37
|
|
26
38
|
|
39
|
+
class main{
|
40
|
+
|
27
41
|
public static void main(String[] args){
|
28
42
|
|
29
|
-
addNo test = new addNo;
|
43
|
+
addNo test = new addNo();
|
30
44
|
|
31
|
-
System.out.println("98765432101");
|
45
|
+
System.out.println(test.addNo("98765432101"));
|
46
|
+
|
47
|
+
}
|
32
48
|
|
33
49
|
}
|
34
50
|
|
2
dd
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
return new String(outData,total);
|
22
22
|
|
23
|
-
|
23
|
+
}
|
24
24
|
|
25
25
|
|
26
26
|
|
1
ss
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,19 +2,19 @@
|
|
2
2
|
|
3
3
|
public String addNo(String inData){
|
4
4
|
|
5
|
-
char[] outData = inData.toCharArray();
|
5
|
+
char[] outData = inData.toCharArray();
|
6
6
|
|
7
|
-
int[] mul = {1,3,7,9,7,3,1,3,9,7,1};
|
7
|
+
int[] mul = {1,3,7,9,7,3,1,3,9,7,1};
|
8
8
|
|
9
|
-
int n = math.min(outData.length,9);
|
9
|
+
int n = math.min(outData.length,9);
|
10
10
|
|
11
|
-
for(innt i = 0; i < n; i++)
|
11
|
+
for(innt i = 0; i < n; i++)
|
12
12
|
|
13
|
-
outData[i] = (char)((outData[i] -'0')* mul[i] % 10+ '0');
|
13
|
+
outData[i] = (char)((outData[i] -'0')* mul[i] % 10+ '0');
|
14
14
|
|
15
|
-
String outData01 = outData.toString();
|
15
|
+
String outData01 = outData.toString();
|
16
16
|
|
17
|
-
total += n;
|
17
|
+
total += n;
|
18
18
|
|
19
19
|
|
20
20
|
|