본문 바로가기

분류 전체보기590

파이썬 연산자 제곱 연산자, 나누기, 몫 연산자a=5rst = a**2rst = 5/2 #파이썬에서는 실수가 나온다.rst = a//2 # 몫 연산자print(rst) 비교 연산자 a=5rst = a==0print(rst)a=5rst = 0 < a < 10 #파이썬에서는 이러한 식도 가능print(rst)rst = 0 < a and a < 10print(rst) 논리 연산자a=5rst = True and Truerst = False and True#rst = True and Truerst = not True ## rst = not []# b=None# rst = not b# print(rst) my = [10,20,30]print(10 in my) s = 'hello korea'print('llo' in s) d = .. 2019. 3. 10.
파이썬 데이터타입 https://python.bakyeono.net/chapter-5-3.html파이썬 데이터타입기본 : 정수, 실수, 불리안복합 : 문자열, 리스트, 튜플, 딕셔너리, 세트 - 순서 있는 자료형 : 문자열, 리스트, 튜플 (인덱스 슬라이싱 가능) - 순서 없는 자료형 : 딕셔너리, 세트 (인덱스 슬라이싱 불가능) - 변경 가능 자료형 : 리스트, 딕셔너리, 세트 - 변경 불가 자료형 : 스트링, 튜플 메모리 할당c언어 : 변수의 자료형에 맞는 메모리 공간을 먼저 확보하고, 그 공간에 값을 넣는다.파이썬 : 객체(모든 데이터 타입은 객체)가 만들어 진 후 변수이름이 그 공간을 참조한다. 인덱스 슬라이싱 & 문자열 함수s=' abc kkk a 's1='###abc###'s2='abc def ghi's3='0.. 2019. 3. 10.
4차 도로건설 완성 코드 bfs는 테케 10개 전부 통과하는데, dfs는 테케 7부터 타임오버 나옴 #include #include #include using namespace std; class POS{public:int r,c;}; #define INF (1 N;for (int i = 0; i > map[i];}}/*void bfs(){queue q;POS pos;for(int i=0; i visit[curPos.r][curPos.c] + map[nextPos.r][nextPos.c] -'0'){visit[nextPos.r][nextPos.c] = visit[curPos.r][curPos.c] + map[nextPos.r][nextPos.c] -'0';q.push(nextPos);}}}}*/ voi.. 2019. 2. 24.
stack으로 dfs 구현 #include #include #include #include using namespace std; int N;//지도 크기char map[110][110];//지도 정보int cMap[110][110];int dirArray[4][2] = { {-1,0}, {0,1}, {1,0}, {0,-1}};int ans = 10e8;int sum; #define VISITED 2#define BACKTRACKED 3 class POS{public:int x=0;int y=0;int curDir=0;int sum=0;}; void Input_Data(){cin >> N;for (int i = 0; i > map[i];}} void dfs(){POS cur;stack s;cur.x = 0.. 2019. 2. 23.