'commit'
This commit is contained in:
45
TangDou/LanQiaoBei/LanQiao11ShengSai/620LCcb6.cpp
Normal file
45
TangDou/LanQiaoBei/LanQiao11ShengSai/620LCcb6.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user