Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 맑은소리 스피치학원
- 오리과
- Birthday paradox
- 딥러닝공부
- 비둘기목
- 백로과
- ADsP
- django
- Python
- 한국의 새
- 흰날개해오라기
- keras
- 딱다구리과
- IBK기업은행 인턴
- AI역량평가
- 계수정렬
- 직박구리과
- structured_array
- AI전략게임
- 딥러닝 공부
- 참새목
- 한국의새
- 생일문제
- 기러기목
- python3
- 참새과
- 가마우지과
- SimpleCraft
- 솔딱새과
- 비둘기과
Archives
- Today
- Total
진박사의 일상
[Goorm] 문자열 번갈아가며 출력하기 (Java, Python 비교) 본문
문자열을 앞뒤로 번갈아가며 출력하는 프로그램을 작성하시오.
[Java]
import java.io.*;
class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input = br.readLine();
while(!input.equals("")){
System.out.print(input.charAt(0));
StringBuffer bf = new StringBuffer(input.substring(1, input.length()));
input = bf.reverse().toString();
}
}
}
[Python]
s = input()
print("".join([s[len(s)-1-i//2] if i%2 else s[i//2] for i in range(len(s))]))
놀라운 Python의 숏 코딩....
'프로그래밍 > 코딩테스트 공부' 카테고리의 다른 글
[백준] 2048 (0) | 2021.11.09 |
---|---|
[프로그래머스] 정렬 문제 - 가장 큰 수 (0) | 2021.09.10 |
[프로그래머스] 힙 문제 - 더 맵게 (0) | 2021.09.10 |
[프로그래머스] 큐 문제 - 주식 가격 (0) | 2021.09.10 |
[프로그래머스] 해시 문제 - 베스트앨범 (0) | 2021.09.10 |