付永康


私信TA

用户名:dotcpp0605582

访问量:811

签 名:

等  级
排  名 3367
经  验 1872
参赛次数 1
文章发表 13
年  龄 0
在职情况 学生
学  校 鄂州职业大学
专  业

  自我简介:

TA的其他文章

解题思路:

注意事项:

参考代码:

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class TT1519 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<String,String> mapInfo = new HashMap<String,String>(); //存储FileName的文件信息
        Map<String,Integer> mapType = new HashMap<String,Integer>(); //存储FileName的数据类型

        while (true) {
            String command = sc.next();

            if (command.equals("exit")) {
                return;
            }

            String FileName = sc.next();
            String str = FileName;

            if (command.equals("create")) { //创建命令
                int FileType = sc.nextInt();
                String FileInfo = sc.next();
                mapInfo.put(FileName,FileInfo); //添加的键为FileName,添加的值为FileInfo
                mapType.put(FileName,FileType); //添加的键为FileName,添加的值为FileType
            } else {
                while (true) {
                    if (mapType.get(str) == 1) { //如果文件类型为1,找到FileName的值,把值赋值给下一次寻找的key
                        str = mapInfo.get(str);
                    } else {
                        System.out.println(mapInfo.get(str));
                        break;
                    }
                }
            }
        }
    }
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区