- package it.ima.test;
- import java.util.Scanner;
- public class Supermarket {
- public static void main(String[] args){
- Scanner in = new Scanner(System.in);
- System.out.println("请会员输入一个4位数会员会员号码:");
- int vipid= in.nextInt();
- String s= Integer.toString(vipid);
- String[] b = s.split("-"); //重点为split()方法,用法自己查API吧;
- for(int i = 0; i < b.length; i++) {
- System.out.println(b[i]+" "); //---- 取开头字母用 sop();
- //int a=Integer.parseInt(b[i]);
- }
- }
复制代码 |