본문 바로가기

프로그래밍

(56)
(파이썬) 백준 알고리즘 11654번 아스키 코드 문제풀이 (Python) 123a = input() print (ord(a))cs키워드 (Keyword)키워드 ord() : 문자의 아스키 코드값을 리턴하는 함수이다.chr() : 아스키 코드값 입력으로 받아 그 코드에 해당하는 문자를 출력하는 함수이다. 참조https://wikidocs.net/32 (점프 투 파이썬-WikiDocs)문제 출처https://www.acmicpc.net/problem/11654
(파이썬) 백준 알고리즘 10039번 평균 점수 문제풀이 (Python) 1234567891011121314a = [0]*5 for i in range(5): a[i] = int(input()) if a[i]
(파이썬) 백준 알고리즘 2178번 미로 탐색 문제풀이 (Python) 123456789101112131415161718192021222324252627282930313233from collections import deque # dx[0], dy[0] => 오른쪽# dx[1], dy[1] => 왼쪽# dx[2], dy[2] => 아래# dx[3], dy[3] => 위dx = [0, 0, 1, -1]dy = [1, -1, 0, 0] n, m = map(int, input().split())a = [list(map(int, list(input()))) for _ in range(n)]q = deque()check = [[False]*m for _ in range(n)]dist = [[0]*m for _ in range(n)] # 시작점q.append(..
(파이썬) 백준 알고리즘 15650번 N과 M(2) 문제풀이 (Python) 123456789101112131415161718import sysn,m = map(int,input().split())c = [False]*(n+1)a = [0]*m def go(index, start, n, m): if index == m: sys.stdout.write(' '.join(map(str,a))+'\n') for i in range(start, n+1): if c[i]: continue c[i] = True a[index] = i go(index+1, i+1, n, m) c[i] = False go(0,1,n,m) Colored by Color Scriptercs 1. 재귀 함수를 사용하여 수열을 만듦2. 중복이 불가능 하기 때문에 check를 사용하여 True이..
(파이썬) 백준 알고리즘 15649 번 N과 M(1) 문제풀이 (Python) 12345678910111213141516171819202122n,m = map(int,input().split()) check = [False]*(n+1)a = [0]*m def go(index, n, m): if index == m: for i in range(m): print (a[i], end = ' ') print() return for i in range(1, n+1): if check[i]: continue check[i] = True a[index] = i go(index+1, n, m) check[i] = False go(0,n,m) Colored by Color Scriptercs 1. 재귀 함수를 사용하여 수열을 만듦2. 중복이 불가능 하기 때문에 check를..
(파이썬) 백준 알고리즘 2309번 일곱 난쟁이 문제 풀이 (Python) 123456789101112131415161718192021n = []for i in range(9): n.append(int(input())) n.sort()total = sum(n)tmp = [] flag = Truefor i in range(len(n)): for j in range(i+1, len(n)): if (total - n[i] - n[j]) == 100: for k in range(len(n)): if i == k or j == k: continue print(n[k]) flag = False break if flag == False: break Colored by Color Scriptercs 1. 일곱 난쟁이의 키의 합은 100이다.2. 아홉명의 키의 합에서..
(파이썬) 백준 알고리즘 2920번 문제풀이 (Python) 123456789a = list(map(int, input().split())) if a == sorted(a): print('ascending')elif a == sorted(a, reverse=True): print('descending')else: print('mixed') Colored by Color Scriptercs키워드 (Keyword)sorted리스트를 정렬 (새로운 리스트 리턴 O)디폴트는 오름차순 정렬해주며 내림차순 정렬시 sorted(list,reverse=True)로 사용한다. 참조장삼용, 초보자를 위한 파이썬 200제, 정보문화사(2017)문제 출처https://www.acmicpc.net/problem/2920
(파이썬) 백준 알고리즘 8958번 문제풀이 (Python) 123456789101112131415161718192021n = int(input()) # 리스트 초기화list = ['' for i in range(n)]count = [0 for i in range(n)] for i in range(n): list[i] = input() for i in range(n): an = 1 for j in range(len(list[i])): if list[i][j] == 'O': count[i] += an an += 1 else: an = 1 for i in range(n): print(count[i]) Colored by Color Scriptercs키워드 (Keyword)문제 출처https://www.acmicpc.net/problem/8958