<>7-3 refuse classification (20 branch )
ljfl.jpg
According to Hong Kong 《 South China Morning Post 》2019 year 7 month 15 Japanese articles , Shanghai's strict new regulations on garbage classification drive many residents crazy . This has led to a lot of help finding the right sort of answers App And applets . At present, at least on wechat 280 Related to garbage disposal App, In Apple's App Store 130 species . Alipay said , Already existing 60 Multiple independent App Developers apply for similar services for the platform .
Please implement a simple garbage sorting assistant on the spot .
Input format :
Input first gives the attribution of each item in the official classification guide . Give a positive integer in a row N(≤10
5
), I.e. number of items ; subsequently N That's ok , Each line gives an item name ( Length not more than 10 Of , A string of lowercase letters and underscores ) And the classification of the article (1 For dry waste ,2
Wet waste ,3 For recyclables ,4 Represents hazardous waste ). Title: make sure that all items have no duplicate names .
Each line then gives the name of the search item ( The format is the same as the item name of the guide ). The last line gives the terminator #, Indicates query termination , This line does not need to be queried .
Output format :
For each item queried , Give the classification in one line :Gan laji For dry waste ;Shi laji Wet waste ;Ke Hui Shou For recyclables ;You Hai
laji Represents hazardous waste . If the item you are looking for is not in the guide , Then output ? I don't know .
sample input :
4
bao_zhi 3
dian_chi 4
dan_ke 2
bei_ke 1
dan_ke
dian_chi
ren_zha
bao_zhi
bei_ke
<>
sample output :
Shi laji
You Hai laji
?
Ke Hui Shou
Gan laji
<> Code
import java.util.HashMap; import java.util.Scanner; /** * Created by IntelliJ
IDEA. * * @Author: Zhang Zhihao Zhang Zhihao * @Email: 3382885270@qq.com * @Date:
2020/5/1 * @Time: 19:55 * @Version: 1.0 */ public class three { public static
void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.
nextInt(); HashMap<String, Integer> hashMap = new HashMap<String, Integer>();
for (int i = 0; i < n; i++) { String str = sc.next(); int num = sc.nextInt();
hashMap.put(str, num); } String[] aaa = {"Gan laji", "Shi laji", "Ke Hui Shou",
"You Hai laji"}; while (sc.hasNext()) { String a = sc.next(); if (!a.equals("#")
) { if (hashMap.get(a) == null) { System.out.println("?"); } else { System.out.
println(aaa[hashMap.get(a) - 1]); // Don't think about wrapping the last line } } } sc.close(); } }
Technology
Daily Recommendation