-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontest.cpp
62 lines (60 loc) · 1.49 KB
/
contest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
struct order
{
int table;
int beef;
//int burrito;
int ceviche;
int fc;
int w;
};
order* createTable()
{
order* temp=(order*)calloc(1,sizeof(order));
temp->table=temp->beef=temp->ceviche=temp->fc=temp->w=0;
return temp;
}
vector<vector<string>> displayTable(vector<vector<string>>& orders)
{
map<char,order*> m;
for(int i=0;i<orders.size();++i)
{
if(m.find(orders[i][1])!=m.end())
{
if(!orders[i][2].compare("Beef Burrito"))
m[orders[i][1]]->beef++;
else if(!orders[i][2].compare("Ceviche"))
m[orders[i][1]]->ceviche++;
else if(!orders[i][2].compare("Fried Chicken"))
m[orders[i][1]]->fc++;
else if(!orders[i][2].compare("Water"))
m[orders[i][1]]->w++
}
else
{
order* temp=createTable();
if(!orders[i][2].compare("Beef Burrito"))
temp->beef++;
else if(!orders[i][2].compare("Ceviche"))
temp->ceviche++;
else if(!orders[i][2].compare("Fried Chicken"))
temp->fc++;
else if(!orders[i][2].compare("Water"))
temp->w++;
m[orders[i][1]]=temp;
}
}
vector<vector<string>> ret;
vector<string> r={"Table","Beef Burrito","Ceviche","Fried Chicken","Water"};
ret.push_back(r);
for(map<int,order*>::iterator itr=m.begin();itr!=m.end();++itr)
{
vector<string> re;
re.push_back(to_string(itr->second->table));
re.push_back(to_string(itr->second->beef));
re.push_back(to_string(itr->second->ceviche));
re.push_back(to_string(itr->second->fc));
re.push_back(to_string(iitr->second->w));
ret.push_back(re);
}
return ret;
}