中国的居民身份证号码长度18位是属于公民个人的敏感信息在系统中显示的时候需要将其中某些字符屏蔽掉用来显示现在给定一个身份证号码要求屏蔽掉中间的第s~t位字符其中1≤s≤t≤18请输出处理后的号码。输入格式一行三个输入项第一个是身份证号;第二个是整数s表示屏蔽的起始位;第三个是整数t表示屏蔽的结束位输出格式一行处理后的身份证号使用java语言编写代码
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String id = sc.nextLine(); int s = sc.nextInt(); int t = sc.nextInt(); String result = id.substring(0, s-1) + "*************".substring(0, t-s+1) + id.substring(t); System.out.println(result); } }
原文地址: https://www.cveoy.top/t/topic/bGKF 著作权归作者所有。请勿转载和采集!