文章
1
粉丝
137
获赞
0
访问
4.2k
模拟法
我使用一个数组来查询每个字符所属的字符串,再用HashMap取映射字符串对应的分组
import java.util.HashMap;
import java.util.Scanner;
public class Main {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
HashMap<String,Integer> hh=new HashMap<String,Integer>();
String []strarr={"abc","def","ghi","jkl","mno","pqrs","tuv","wxyz","-"};
hh.put("abc",1);
hh.put("def",2);
hh.put("ghi",3);
hh.put("jkl",4);
hh.put("mno",5);
hh.put("pqrs",6);
hh.put("tuv",7);
hh.put("wxyz",8);
hh.put("-",9);
while(sc.hasNext())
{
String h=sc.nextLine();
char lastselect='-';
String lastcatgol="-";
int time=0;
for(int i=0;i<h.length();i++)
{
char cur=h.charAt(i);
String catgolaries="";
int pos=0;
//查分类
...
登录后发布评论
暂无评论,来抢沙发