-
백준 11721번 _ C++ 열 개씩 끊어 출력하기소프트웨어전공/알고리즘 문제풀이 2021. 9. 21. 14:37
코드 풀기전 생각
11720번과 유사하게 짤 수 있을 듯10번째 마다 개행을 하면 풀 수 있지 않을까?10번째를 구분하려면 count++를 이용해서 하면 될거 같다.count가 10의 배수이면 개행 처리결국 구글링 행..
1. C언어 스타일 풀이 _ while문 활용
while로 입력받는 조건 설정 _ 이렇게도 쓸 수 있다
아직 while(), 특히 ()안에서 활용할 수 있는게 많은데 전혀 모른다..
2. C++ with string
<string>으로 푸는 방법. 구글링을 통해 찾아보면 가장 많이 나오는 방법이다.
포인트는 반복문 속의 조건문인데, index가 0부터 시작하므로 i % 10 == 9 로 해줘야 한다.
나의 경우 초기에 코드를 짤 때, i % 10 == 0으로 짰더니, i가 0일때 즉 첫번째 배열의 요소 출력 이후에 바로 줄바꿈이 실행되는 것을 확인했다.
3. getline()을 이용한 풀이
입출력 기본을 다시 공부하자.
'소프트웨어전공 > 알고리즘 문제풀이' 카테고리의 다른 글
백준 1924번 _ 2007년 x월 y일은 무슨 요일? [C++] (0) 2021.09.23 백준 2741번 _ C++ ( 시간초과 해결하기 ) (0) 2021.09.22 C++ 모두의 약수 ( 제한시간 1초 ) (0) 2021.09.21 C++ 모두의 약수 (0) 2021.09.21 백준 11720번 _ C++ 입출력 (0) 2021.09.21