목록Homework (40)
without haste but without rest

ADT 구현, 사각형 문제 #include #include typedef struct _coordinates { int x; int y; } Point; void input(Point *p); void output(Point p); double distance(Point pt1, Point pt2); int area(Point pt1, Point pt2); int equals(Point pt1, Point pt2); void move(Point* pt1, Point vec); int test() { Point p1, p2, vec; printf(">>"); input(&p1); printf(">>"); input(&p2); if (equals(p1, p2)) { printf("두 점이 같습니다."); r..

#define _CRT_SECURE_NO_WARNINGS #include void move(int n, char from, char to) { printf("원판%d을 %c에서 %c로 이동합니다.\n", n, from, to); } void hanoi_tower(int n, char from, char tmp, char to) { if (n == 1) move(n, from, to); else { hanoi_tower(n - 1, from, to, tmp); move(n, from, to); hanoi_tower(n - 1, tmp, from, to); } } int main(void) { hanoi_tower(3, 'A', 'B', 'C'); return 0; }

제곱 연산의 과정을 출력하는 과제 #define CRT_SECURE_NO_WARNINGS #include int count = 0; double res; void depth(int n) { for (int i = 0; i 0) { depth(count++); printf("power(%.3lf, %d)\n", d, n); } if (n == 0) { count--; return 1; } else if (n % 2 == 0) res = power(d * d, n / 2); else res = d * power(d * d, (n - 1) / 2); if (n > 1) { depth(--coun..

경기 기록 import random def groups(n, j): res = [] while(True): if n - j > 0: n -= j res.append(j) else: res.append(n) break return res def make_score(n, name, count): tmp = [] for _ in range(n): scores = [random.randint(100, 180) for _ in range(count)] tmp.append(scores) res = list(zip(name, tmp)) return res def divide_group(n, total_list, group): res = [] tmp = [0] + group order = [] sum = 0 for a..

포커 import random # 스트레이트: 연속된 네개 숫자, A432나 AKQ2도 연속이라고 봄 # 숫자 부분을 'AKQJ98765432'에서의 위치로 정렬, 연속인가 검사 def strait(hand): nlist = [] for s, a in hand: nlist.append(numbers.index(a)) nlist.sort() for i in range(1, 4): if nlist[i] == 0 and nlist[i - 1] == 11: continue if nlist[i] != nlist[i - 1] + 1: return False # print(' ', nlist, end=' ') return True # 플러시: 같은 모양 네장 def flush(hand): for a in range(..

10진수, 12진수 변환 def tenToTwe(n): tempList = [] check = n while(1): letter = check % 12 check = check // 12 if letter == 10: res = 'a' elif letter == 11: res = 'b' else: res = str(letter) tempList.append(res) if check == 0: break tempList.reverse() result = ''.join(tempList) return result def tweToTen(n): tempList = list(n) resList = [] res = 0 for a in tempList: if a == 'a': temp = 10 elif a == 'b..

가장 차이가 큰 항 구하기 import random def max_value(x, y): xlist = [random.randint(x, y) for _ in range(10)] ylist = [random.randint(x, y) for _ in range(10)] res = [] print(xlist, ylist, sep='\n', end='\n\n') for i, a in enumerate(xlist): res.append(abs(a - ylist[i])) check = res.index(max(res)) for i, a in enumerate(xlist): if i == check: print("( {})".format(xlist[i]), end='\t') else: print(xlist[i], ..

0. 개요 1. 분석 전에 데이터를 살펴보는 방법 - 박스 플롯 & 바이올린 플롯 - 페어 플롯 - lm 플롯 2. 차원축소 (피쳐 엔지니어링) - PCA - LDA 1. 데이터 불러오기 (1) 데이터 로드 import pandas as pd df = pd.read_csv("./data/iris.csv") # sanity check with Pandas print("shape of data in (rows, columns) is " + str(df.shape)) print(df.head()) df.describe().transpose() df.describe() 는 데이터 프레임에 대한 기술을 하라는 메소드 transpose()는 전치 함수 (2) 속성 확인(attributes check) print(d..