第一题
package step1;
import java.util.Scanner;
public class EasyString {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String str = input.nextLine();
input.close();
char head = ' ';
char end = ' ';
int length = 0;
//请在指定位置填写代码。
/********* Begin *********/
length=str.length();
head=str.charAt(0);
end=str.charAt(str.length()-1);
/********* End *********/
System.out.print(String.format("%d %c %c", length, head, end));
}
}
第二题
package step2;
import java.util.Scanner;
public class SSN {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String ssn = input.nextLine();
input.close();
String output = "";
//请在指定位置填写代码。
/********* Begin *********/
output = "yes";
if(Character.isDigit(ssn.charAt(0))){
output = "yes";
}
else{
System.out.print(output="no");
System.exit(0);
}
if(Character.isDigit(ssn.charAt(1))){
output = "yes";
}
else{
System.out.print(output="no");
System.exit(0);
}
if(Character.isDigit(ssn.charAt(2))){
output = "yes";
}
else{
System.out.print(output="no");
System.exit(0);
}
if('-' == ssn.charAt(3)){
output = "yes";
}
else{
System.out.print(output="no");
System.exit(0);
}
if(Character.isDigit(ssn.charAt(4))){
output = "yes";
}
else{
System.out.print(output="no");
System.exit(0);
}
if(Character.isDigit(ssn.charAt(5))){
output = "yes";
}
else{
System.out.print(output="no");
System.exit(0);
}
if('-' == ssn.charAt(6)){
output = "yes";
}
else{
System.out.print(output="no");
System.exit(0);
}
if(Character.isDigit(ssn.charAt(7))){
output = "yes";
}
else{
System.out.print(output="no");
System.exit(0);
}
if(Character.isDigit(ssn.charAt(8))){
output = "yes";
}
else{
System.out.print(output="no");
System.exit(0);
}
if(Character.isDigit(ssn.charAt(9))){
output = "yes";
}
else{
System.out.print(output="no");
System.exit(0);
}
if(Character.isDigit(ssn.charAt(10))){
output = "yes";
}
else{
System.out.print(output="no");
System.exit(0);
}
if(Character.isDigit(ssn.charAt(11))){
output = "yes";
}
else{
System.out.print(output="no");
System.exit(0);
}
if(ssn.length() != 12){
output = "no";
}
/********* End *********/
System.out.print(output);
}
}
第三题
package step3;
import java.util.Scanner;
public class SubString {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String name = input.nextLine();
input.close();
//请在指定位置填写代码。
/********* Begin *********/
if(name.contains("*")){
System.out.println(name.replaceAll(" ","").substring(0,2));
System.out.print(name.replaceAll(" ","").substring(2,name.replaceAll(" ","").length()-1));
}
else{
System.out.println(name.replaceAll(" ","").substring(0,1));
System.out.print(name.replaceAll(" ","").substring(1,name.replaceAll(" ","").length()));
}
/********* End *********/
}
}
第四题
CEHI