-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path181837.cpp
More file actions
24 lines (21 loc) · 1.18 KB
/
Copy path181837.cpp
File metadata and controls
24 lines (21 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*팀의 막내인 철수는 아메리카노와 카페 라테만 판매하는 카페에서 팀원들의 커피를 사려고 합니다. 아메리카노와 카페 라테의 가격은 차가운 것과 뜨거운 것 상관없이 각각 4500, 5000원입니다.
각 팀원에게 마실 메뉴를 적어달라고 하였고,
그 중에서 메뉴만 적은 팀원의 것은 차가운 것으로 통일하고
"아무거나"를 적은 팀원의 것은 차가운 아메리카노로 통일하기로 하였습니다.
각 직원이 적은 메뉴가 문자열 배열 `order`로 주어질 때
카페에서 결제하게 될 금액을 return 하는 solution 함수를 작성해주세요.
`order`의 원소는 아래의 것들만 들어오고, 각각의 의미는 다음과 같습니다.*/
#include <string>
#include <vector>
#include<iostream>
using namespace std;
int solution(vector<string> order) {
int tot = 0;
int size = order.size(); // 주문크기 저장
for (int i = 0; i < size; ++i) {
if (order[i].find("cafelatte") != string::npos) tot += 5000;
/**order[i] 문자열에서 cafelatte를 찾음. 존재한다면 인덱스 반환, 존재하지 않으면 string:npos 반환*/
else tot += 4500;
}
return tot;
}