📄 main_1002_2.java
字号:
package acm;
import java.io.IOException;
import java.util.Vector;
public class Main_1002_2 {
public void toString(Vector<Character> v1) {
for (int m = 0; m < 3; m++) {
System.out.print(v1.elementAt(m));
}
System.out.print("-");
for (int m = 3; m < 7; m++) {
System.out.print(v1.elementAt(m));
}
}
public Vector<Character> matchTheNumer(String x) throws IOException {
char y[] = x.toLowerCase().toCharArray();
// convert the identifier to the numbers.
for (int z = 0; z < y.length; z++) {
if (y[z] == 'a' | y[z] == 'b' | y[z] == 'c') {
y[z] = '2';
}
if (y[z] == 'd' | y[z] == 'e' | y[z] == 'f') {
y[z] = '3';
}
if (y[z] == 'g' | y[z] == 'h' | y[z] == 'i') {
y[z] = '4';
}
if (y[z] == 'j' | y[z] == 'k' | y[z] == 'l') {
y[z] = '5';
}
if (y[z] == 'm' | y[z] == 'n' | y[z] == 'o') {
y[z] = '6';
}
if (y[z] == 'p' | y[z] == 'r' | y[z] == 's') {
y[z] = '7';
}
if (y[z] == 't' | y[z] == 'u' | y[z] == 'v') {
y[z] = '8';
}
if (y[z] == 'w' | y[z] == 'x' | y[z] == 'y') {
y[z] = '9';
}
if (y[z] == 'q' | y[z] == 'z') {
y[z] = '1';
}
}
// delete the other elements.
// vector to accept the new array's elements
Vector<Character> v = new Vector<Character>();
for (int m = 0; m < y.length; m++) {
if (y[m] >= 48 && y[m] <= 57) {
v.addElement(y[m]);
}
}
return v;
/*
* this moment,we have already known that length of the vector is 7, so
* we should set the format.
*/
// set the format and output,
// just reWrite the toString() method.
// this.toString(v);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -