https://softeer.ai/practice/info.do?idx=1&eid=623 

 

Softeer

연습문제를 담을 Set을 선택해주세요. 취소 확인

softeer.ai

#include<iostream>
#include<vector>
#include<string>
using namespace std;
bool replace_all(string& inout, string_view what, string_view with)
{
    size_t count{};
    for (string::size_type pos{};
         inout.npos != (pos = inout.find(what.data(), pos, what.length()));
         pos += with.length(), ++count) {
        inout.replace(pos, what.length(), with.data(), with.length());
		return true;
    }
    return false;
}
int main(int argc, char** argv)
{
	//회사 식당 전설 메뉴
	//식판자파긴 특정 순서대로 누르고 결제

	//이 식권을 배식대에 제출하면 다른 메뉴 
	//자판기는 총 k개의 버튼
	// 각 버튼 마다  1~k 번호가 붙어 잇어서
	// 조작 과정은 1이상 ~ k이하 정수 여러개로 나타낼수 잇음
	// m개의 버튼 조작으로 이루어져 잇다 
	// 사용자가 누른 n개으,ㅣ 버튼 조작이 주어질때 
	// 비밀메뉴 식권을 받을수 있는지를 확인하는 프로그램을 작성
     //비밀식구너을 받을수 있으면 secret , 그렇지 않다면 normal 

	/*
	3 10 5 << 총 조작 번호 갯수 k:3, m개의 버튼 조작 :10 ,사용자가 누른 n: 5(1~5)  
	1 4 5 <조작 번호 
	3 3 1 2 4 1 4 5 1 4
*/
   int k,m,n;
   cin>>m;
   cin>>n;
   cin>>k;
   vector<int> answer;
   string answerStr="";
   for(int i=0;i<m;i++){
	   int tmpAnswer;
	   cin>>tmpAnswer;
	   if(tmpAnswer<=k){
			answer.push_back(tmpAnswer);
			answerStr=answerStr+to_string(tmpAnswer);
	   }
	   
   }
   vector<int> userInput;
   string inputStr="";
    for(int i=0;i<n;i++){
	   int tmpinput;
	   cin>>tmpinput;
	   if(tmpinput<=k){
	   	userInput.push_back(tmpinput);
		inputStr=inputStr+to_string(tmpinput);
	   }
   }
   
   int count=0;
   int check=0;
   string coupon="normal";
  // string tmp;
   auto bCheck=replace_all(inputStr, answerStr, "secret");
   if(bCheck==true){
	   cout<<"secret";
   }else {
		cout<<"normal";
   }
	

	return 0;
}

'알고리즘 공부' 카테고리의 다른 글

금고털이  (0) 2023.03.02
택배 마스터 광우  (0) 2023.03.02
전광판  (0) 2023.03.02
회의실 예약  (0) 2023.03.02
프로그래머스 -2019 KAKAO BLIND RECRUITMENT 오픈채팅방-연습문제  (0) 2021.09.26

+ Recent posts