본문 바로가기

프로그래밍/Baekjoon

(52)
(C언어) 백준 알고리즘 1157번 단어 공부 문제풀이 (C언어) 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758#include #include #include #define MAX 1000000 void upper(char *str); int alpha[26] = {0,}; int main(){ char word[MAX]; int i, index; int max = 0; int flag = 0; int len; scanf("%s", word); upper(word); len = strlen(word); for(i = 0; i
(파이썬) 백준 알고리즘 2675번 문자열 반복 문제풀이 (Python) 1234567T = int(input()) for i in range(T): R, S = input().split() for k in S: print(k*int(R), end='') print()cs문제 출처https://www.acmicpc.net/problem/2675
(파이썬) 백준 알고리즘 10809번 알파벳 찾기 문제풀이 (Python) 1234567891011S = input()check = [-1]*26 for i in range(len(S)): if check[ord(S[i])-97] != -1: continue else: check[ord(S[i])-97] = i for i in range(26): print(check[i], end=' ')cs소문자 a는 아스키코드로 97이다.문자를 아스키코드로 변환하여 97을 뺀 인덱스에 문자열 위치를 입력해준다.ex a=97 이므로 97-97 = 0 이여서 check[0]에 문자열의 위치 i를 넣어준다. 문제 출처https://www.acmicpc.net/problem/10809
(파이썬) 백준 알고리즘 2839번 설탕 배달 문제풀이 (Python) 1234567891011121314151617181920212223n = int(input())# 초기화five = 0three = 0 # 최대 5kg의 갯수와 나머지를 구한다.five = n//5b = n%5 # 나머지가 0이 아니면 3kg 갯수를 구한다.if b !=0: while five >= 0: if b%3 == 0: three = b//3 break five -= 1 b += 5 ret=five + three if ret
(파이썬) 백준 알고리즘 4673번 셀프 넘버 문제풀이 (Python) 123456789101112131415161718192021def self_num(x): a = int(x) if a > 10000: return else: for j in range(len(x)): a += int(x[j]) if a > 10000: return check[a] = True self_num(str(a)) check = [False]*10001 for i in range(1, 10000): self_num(str(i)) for i in range(1, 10000): if check[i] ==False: print(i) Colored by Color Scriptercs1 ~ 11 : 셀프 넘버가 아니면 해당하는 값의 check 인덱스에 True 값을 주는 함수이다...
(파이썬) 백준 알고리즘 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(..