정신과 시간의 방

코딩테스트/문제풀이 36

카테고리 설명
  • 문제 풀이#include using namespace std;int main(){ int diceInput[3] = {}; int valueCount[7] = {}; int result = 0; int maxIndex = 0; for (int i = 0; i > diceInput[i]; } for (int i = 0; i  메모중복 되는 숫자를 찾기 위해 valueCount를 사용했다. 이때 diceInput[i] 에 해당하는 주사위 값 자체를 인덱스로 사용해서 입력받은 값을 쉽게 비교할 수 있도록 만들었다.

  • 문제 풀이#include #include using namespace std;int main() { int n = 0; cin >> n; stack st; string str; for (int i = 0; i > str; if (str == "push") { int input = 0; cin >> input; st.push(input); } else if (str == "pop") { if (false == st.empty()) { cout   메모front, pop 함수를 실행하기 전에 empty 함수로 스택 내부가 비어있는지 확인하는 것을 주의해야 한다.

  • 문제 풀이#include #include #include using namespace std;int main() { std::ios::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL); while (true) { string str = ""; getline(cin, str); if (str == ".") { break; } int flag = 0; stack s; int strLength = str.length(); for (int i = 0; i  다시 풀이 (24-11-10)#include #include #include using namespace std;int main(){ ios::sync_with_stdi..

  • 문제 풀이#include #include using namespace std;int main(){ int k = 0; cin >> k; stack s; for (int i = 0; i > input; if (input != 0) { s.push(input); } else { s.pop(); } } int size = s.size(); int sum = 0; for (int i = 0; i

  • 문제 풀이#include using namespace std;int main(){ int N = 0, X = 0, input = 0; cin >> N >> X; for (int i = 0; i > input; if (input  다시 풀기 (2024-10-28)#include using namespace std;int n, x, input;int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> n >> x; for (int i = 0; i > input; if (input  다른 풀이 (출처 : https://blog.encrypted.gg/923)#include using namespace std;int main(void..

  • 문제 풀이#include using namespace std;int main(){ int A = 0, B = 0; cin >> A >> B; cout

  • 문제 풀이#include using namespace std;int main(){ cout  메모출력시 특수문자 백슬래시 \가 들어가는 경우 실행시에 \와 조합해서 사용할 수 있는 이스케이프 시퀀스(ex. \n, \t, \b)라는 일종의 메크로로 인식하게 되어 올바르게 출력이 되지 않는 문제가 발생한다.따라서 백슬래시 \ 하나만 출력하길 원하는 경우 \ + \ 로 \를 하나 더 붙여서 출력해줘야 정상적인 결과를 얻게 된다.

  • 문제 풀이#include using namespace std;void print(int score){ if (score >= 90 && score = 80 && score = 70 && score = 60 && score > score; print(score); return 0;}