Files
python/TangDou/LanQiaoBei/LanQiao11ShengSai/620LCcb6.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

46 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
const int N = 4;
string a[N] = {"FOOD WASTE", "RECYCLABLE", "HAZARDOUS", "RESIDUAL WASTE"};
unordered_map<string, int> m;
int b[N]; //计数用的桶
/*
5
leaves
mask
disinfectant
leftovers
watermelon peel
*/
int main() {
//初始化数据
m["leaves"] = m["watermelon"] = m["leftovers"] = 0;
m["paper box"] = m["plastic botte"] = m["clothes"] = 1;
m["rechargeable battery"] = m["abandoned medicine"] = m["disinfectant"] = 2;
m["mask"] = m["battery"] = m["plastic bag"] = 3;
int n; //表示本次要录入多少个垃圾名称,比如10
cin >> n;
//对于输入的N个名称开始逐个录入~
cin.ignore(); //这是处理cin读入带空格字符串的标准用法
for (int i = 0; i < n; i++) {
string str;
getline(cin, str);
cout << str << endl;
b[m[str]]++;
}
//找出最大值
int Max = 0;
int num = 0;
for (int i = 0; i < 4; i++) {
if (Max < b[i]) {
Max = b[i];
num = i;
}
}
//输出结果
cout << a[num] << endl;
cout << Max << endl;
return 0;
}