소프트웨어전공
-
백준 1924번 _ 2007년 x월 y일은 무슨 요일? [C++]소프트웨어전공/알고리즘 문제풀이 2021. 9. 23. 18:28
[풀이 시도] 정말 쉬워보였는데, 막상 풀려니 결국 못풀었다.. 문제에 있는 참고 정보에 따라 조건문을 나누는 식으로 31일, 30일 ,28일 이렇게 풀어내려고 했는데 그게 아니였음. 구글링으로 다양한 풀이들을 직접 따라해보면서 모르는 구현들을 줍줍하자.. 구글에 c++ 1924로 검색해서 1페이지에 뜨는것 코드들을 순서대로 참고했다. 1. switch & case 조건문 활용 32줄 이하는 생략. 코드가 다소 길지만, 요일을 나누는게 직관적으로 보여서 따라 구현해보았다. 2. string 배열을 활용
-
C++ string 정리 (1)소프트웨어전공/C++ Programming 2021. 9. 22. 13:46
https://blockdmask.tistory.com/338 [C++] string 클래스, 문자열에 대해서 (총정리) 안녕하세요 BlockDMask 입니다. 오늘은 C++의 std::string 클래스(문자열)에 대해서 세세 하게 알아볼것 입니다. 예전 글을 보다가 제가 작성한 이 문서를 보게 되었는데요, 너무 내용이 빈약하다고 blockdmask.tistory.com 어떤 분께서 좋은 자료를 올려두어 이를 통해 공부했다. 내용이 적지 않아서 당장 필요한 것들 위주로 우선 정리! 1. string 선언 char*, char[] 과는 달리 문자열 끝에 '\0'이 들어있지 않다. Null문자가 뒤에 따로 없다는 것..! 2. string 클래스의 함수들 정리 - 양이 많아서 몇가지만 살펴보기로 했다. ..
-
C++ 모두의 약수 ( 제한시간 1초 )소프트웨어전공/알고리즘 문제풀이 2021. 9. 21. 20:46
문제는 https://markson.tistory.com/4 C++ 모두의 약수 일단 문제를 풀기 전에 종이에 나름 구현을 해보았다. 이중 for문을 이용하여 개수를 ++하는 방식으로 풀면 쉽겠다고 했는데 이상하리 엉뚱한 값이 나와서 해설을 보니.. 각 숫자의 약수의 개수이 markson.tistory.com 위의 풀이로는 시간제한을 통과하지 못하므로.. 문제는 오래 고민해도 이걸 떠올리기 쉽지 않다는 거.. 발상하는 과정을 따라 익히는 수 밖에 없다 -> 일일이 약수를 찾는게 아니라 배수의 관점에서 생각해 볼것.. "어떻게 하면 불필요한 연산을 제외하고 원하는 결과값을 얻을 수 있는가?" 특별한 발상이 아니라, 결국 위 질문으로부터 시작해서 이것저것 시도해 보는 태도가 필요하다.
-
C++ 모두의 약수소프트웨어전공/알고리즘 문제풀이 2021. 9. 21. 20:23
문제 출처 https://www.inflearn.com/course/%EC%95%8C%EA%B3%A0%EB%A6%AC%EC%A6%98/ it 취업을 위한 알고리즘 문제풀이 (with C/C++) : 코딩테스트 대비 - 인프런 | 강의 알고리즘과 자료구조를 이용해 문제해결력을 기르는게 주 목적입니다., 문제를 풀면서 자료구조와 알고리즘 기초·중급 개념을 확실히 잡고 다양한 문제를 통해 어떤 문제도 해결할 수 있는 문 www.inflearn.com 일단 문제를 풀기 전에 종이에 나름 구현을 해보았다. 이중 for문을 이용하여 개수를 ++하는 방식으로 풀면 쉽겠다고 했는데 이상하리 엉뚱한 값이 나와서 해설을 보니.. 각 숫자의 약수의 개수이기 때문에 개수를 i 마다 초기화 시켜줘야 한다.. "문제를 토씨 하나..
-
백준 11721번 _ C++ 열 개씩 끊어 출력하기소프트웨어전공/알고리즘 문제풀이 2021. 9. 21. 14:37
코드 풀기전 생각 11720번과 유사하게 짤 수 있을 듯 10번째 마다 개행을 하면 풀 수 있지 않을까? 10번째를 구분하려면 count++를 이용해서 하면 될거 같다. count가 10의 배수이면 개행 처리 결국 구글링 행.. 1. C언어 스타일 풀이 _ while문 활용 while로 입력받는 조건 설정 _ 이렇게도 쓸 수 있다 아직 while(), 특히 ()안에서 활용할 수 있는게 많은데 전혀 모른다.. 2. C++ with string 으로 푸는 방법. 구글링을 통해 찾아보면 가장 많이 나오는 방법이다. 포인트는 반복문 속의 조건문인데, index가 0부터 시작하므로 i % 10 == 9 로 해줘야 한다. 나의 경우 초기에 코드를 짤 때, i % 10 == 0으로 짰더니, i가 0일때 즉 첫번째 배..
-
백준 11720번 _ C++ 입출력소프트웨어전공/알고리즘 문제풀이 2021. 9. 21. 13:48
문제를 보고 우선 배열을 떠올렸다. 숫자가 공백없이 쓰여있고, 배열의 각 인덱스에 숫자를 차례대로 넣은 다음 배열의 요소를 모두 더해서 출력하면 될것이라 생각 그러나, 배열로는 결국 구현하지 못했다..! 구글링으로 여러 코드를 참조했는데, 풀이 방법은 다양했다. 1. 아스키 코드를 활용해서 푸는 법 입출력 문제에서 계속 헤매는 이유가 cin을 잘 몰라서 그렇다고 생각한다 아스키 코드를 써서 풀어도 되겠다는 생각은 했었지만, char에 N번만큼 값을 하나하나 담는다는것? 아직 이해가 완벽하게 안된다. -> char에는 단 하나의 문자만 담기니까, 12345라는 입력에는 1/2/3/4/5 이렇게 공간이 할당될 것이다. 2. 배열을 활용해서 푸는 법 내가 처음 문제를 풀때 떠올린 방법과 유사하다.