글

8월, 2022의 게시물 표시

[C] C언어, 구조체_단어빈도수 세기 프로그램

 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<string.h> #include<ctype.h> #define NSIZE 1000 struct symtab { char sym[20]; int count; }; int searchword(struct symtab tbl[], int size, char word[]); int getword(char s[]); int main(void) { struct symtab table[NSIZE]; int longstring = 0; int n = 0; char s[80]; int i; for (i = 0; i < NSIZE; i++) { table[i].count = 0; } while (getword(s)) { if (strlen(s) >= 20) { longstring++; continue; } i = searchword(table, n, s); if (i < 0) { if (n >= NSIZE) { printf("no size with symbol table"); break; } i = n++; strcpy(table[i].sym, s); } table[i].count++; } for (i = 0; i < n; i++) { printf("$-20s: %d\n", table[i].sym, table[i].count); } printf("%-20s: %d\n", "길이 20이상의 단어", longstring); return 0; } //단어 탐색 함수 int searchword(struct symtab tbl[], int size, char word[]) { int i; ...

[Python] 파이썬 Gui, Pillow 라이브러리 이용한 포토샵 프로그램 만들기

from tkinter import * from tkinter.filedialog import * from tkinter.simpledialog import * #이미지 처리 기능 제공, Pillow 라이브러리 from PIL import Image, ImageFilter, ImageEnhance, ImageOps #전역변수 선언 window, canvas, paper = None, None, None photo_1, photo_2 = None, None orix, oriy = 0, 0 def displayImage(img, width, height):     global window, canvas, paper, photo_1, photo_2, orix, oriy     #화면 크기를 width, height에 맞춰 설정     window.geometry(str(width)+"x"+str(height))     print(str(width), str(height))     if canvas != None: #기존에 canvas에 출력한 그림이 존재 시         canvas.destroy() #canvas 를 지움     canvas = Canvas(window, width= width, height = height) #캔버스 생성     paper = PhotoImage(width=width, height=height)      #이미지의 사이즈 절반의 값의 위치에 이미지 생성(paper에 그리기 위해서)     canvas.create_image((width/2, height/2),image=paper)      rgbString=""     rgbImage=img.convert('RGB')   ...