[C++] 프로그래머스 위클리챌린지 5주차 모음사전
·
Algorithm/Programmers
#include #include using namespace std; void solve(int &x, const string& word, string result, int& sum); int solution(string word) { int answer = 0; int num = 0; solve(num, word, "", answer); return answer; } void solve(int &x, const string& word, string result, int &sum) { if (word == result) sum = x; else if (word != result) { if(result.length() >= 0 && result.length()
[C++] 프로그래머스 위클리챌린지 4주차 직업군추천하기
·
Algorithm/Programmers
#include #include #include #include #include #include using namespace std; bool sortSolve(pair a, pair b); void saveTable(const vector& table, vector& tableSum, vector& tablePoint); //테이블 점수들을 저장 string solution(vector table, vector languages, vector preference) { string answer = ""; vector tableSum; //직업군 저장과 vector tablePoint; //직업군별 포인트 저장 saveTable(table, tableSum, tablePoint); for (int i = ..
[C++] 프로그래머스 위클리챌린지 3주차 퍼즐조각채우기
·
Algorithm/Programmers
#include #include #include #include using namespace std; //type = 보드는 0, 테이블은 1을 확인 void Check(int type, vector& type_board, vector& puzzle); //90도만큼씩 돌려보면서 같은 도형의 개수를 찾는다. int Degree(vector boards, vector tables); int solution(vector game_board, vector table) { int answer = -1; vector boards; vector tables; Check(0, game_board, boards); Check(1, table, tables); answer = Degree(boards, tables); ..
[C++] 프로그래머스 실패율
·
Algorithm/Programmers
#include #include #include #include using namespace std; bool sortSolve(pair a, pair b); vector solution(int N, vector stages) { vector answer; map stageNon; map stageClear; vector nonClear; //실패율 for (int i = 0; i = stages[i] && j == 0) stageNon[sta..
[C++] 프로그래머스 위클리챌린지 2주차 상호평가
·
Algorithm/Programmers
#include #include #include using namespace std; string solve(float x); string solution(vector scores) { string answer = ""; int counts = scores.size(); for(int j = 0; j < counts; j++) { int maxScore = -1; int minScore = 101; bool equal = false; float sum = 0; for(int i = 0; i < counts; i++) { sum += scores[i][j]; if(scores[j][j] == scores[i][j] && i != j)//i != j로 자기자신은 제외 equal = true; maxScore..
함수 오버로딩
·
C++/Basic
함수오버로딩 매개변수의 내용이 다르고 이름이 같은 함수들을 만들 수 있게 해주는 기능 //가능 void hi(int x, int y) { ... } void hi(double x, double y) { ... } 1. 매개변수의 내용이 다른 같은 이름의 여러 함수를 만든다. //가능하지 않음 void hi(int x, int y) { ... } void hi(double x, double y) { ... }//void double hi(double x, double y) { ... }//double 2. 매개변수의 내용이 같고 반환타입이 다른 여러함수는 안 된다. //모호함 void hi(float x) { ... } void hi(unsigned int x) { ... } hi(2.142332);//모..