본문 바로가기

전체 글

(304)
(Python) 백준 25373번 https://www.acmicpc.net/problem/25373 25373번: 벼락치기 부산사이버대학교에 다니는 대희는 강의 영상 보는 것을 매일 미뤘다. 오늘은 중간고사가 일주일 남은 날이다. 대희는 더 이상 미루면 큰일이 날 것 같아서 오늘부터 밀린 영상을 보기로 했다. www.acmicpc.net 첫날 봐야 하는 영상 개수가 최솟값이어야 합니다. ( 인강을 7개 들어야 한다면 첫째 날에 그냥 벼락치기 방법은 안된다는 것이죠... ) N = 1이면 1 N = 2이면 2 N = 3이면 2 1 N = 4이면 3 1 N = 5이면 3 2 N = 6이면 3 2 1 N = 7이면 4 3 N = 8이면 4 3 1 N = 9이면 4 3 2 N = 10이면 4 3 2 1 N = 11이면 5 3 2 1 N = 1..
( Python ) 백준 1676번 https://www.acmicpc.net/problem/1676 1676번: 팩토리얼 0의 개수 N!에서 뒤에서부터 처음 0이 아닌 숫자가 나올 때까지 0의 개수를 구하는 프로그램을 작성하시오. www.acmicpc.net N = int(input()) sum = 1 for i in range(1,N+1): sum *=i sum1 = list(str(sum)) print(sum1.count('0')) N = int(input()) sum = 1 num = 0 for i in range(1,N+1): sum *=i for j in range(len(str(sum))): if sum%10 !=0: break sum//=10 num+=1 print(num) 첫 풀이가 오답인 이유는 sum1의 값에서 0의 개..
( C ) SW Expert Academy 9658번 https://swexpertacademy.com/main/code/problem/problemDetail.do SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com #include int main() { int t; scanf("%d", &t); int N, num; double total; for (int i = 0; i 3) { for (int j = 0; j = 5) { N = N / 10 ..
( C ) SW Expert Academy 1859번 https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=1&contestProbId=AV5LrsUaDxcDFAXc&categoryId=AV5LrsUaDxcDFAXc&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=1&pageSize=10&pageIndex=1 SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com #include int arr[1000000]; int main(void) { int..
열혈 ( C ) chapter 23 정리노트 1 typedef 선언 typedef 선언은 기존에 존재하는 자료형의 이름에 새 이름을 부여하는 것을 목적으로 하는 선언이다. #include typedef int INT; typedef int* PTR_INT; typedef unsigned int UINT; typedef unsigned int* PTR_UINT; typedef unsigned char UCHAR; typedef unsigned char* PTR_UCHAR; int main(void) { INT num1 = 120; PTR_INT pnum1 = &num1; UINT num2 = 190; PTR_UINT pnum2 = &num2; UCHAR ch = 'z'; PTR_UCHAR pch = &ch; printf("%d, %u, %c \n", *..
열혈 ( C ) chapter 22 - 구조체와 배열 그리고 포인터 #include struct point { int xpos; int ypos; }; int main(void) { struct point arr[3]; int i; for (i = 0; i < 3; i++) { printf("점의 좌표 입력: "); scanf("%d %d", &arr[i].xpos, &arr[i].ypos); } for (i = 0; i < 3; i++) printf("[%d,%d] ", arr[i].xpos, arr[i].ypos); return 0; } point라는 이름의 구조체를 정의하였고, 이때 point라는 이름이 int나 double과 같은 자료형의 이름이 된다. 즉 사용자 정의 자료형이라 부를 수 있다. int xpos; int ypos; 를 구조체의 멤버라고 부른다. 다..
열혈 ( c ) chapter 22-구조체의 정의 #include #include struct point { int xpos; int ypos; }; int calculate(int A, int B,int C,int D) { return sqrt((A - B) * (A - B) + (C - D) * (C - D)); } int main(void) { struct point pos1, pos2; double distance; fputs("point1 pos: ", stdout); scanf("%d %d", &pos1.xpos, &pos1.ypos); fputs("point2 pos: ", stdout); scanf("%d %d", &pos2.xpos, &pos2.ypos); distance = calculate(pos1.xpos, pos2.xpos, po..
열혈 ( C ) chapter 21 정리노트 5 문자열을 덧붙이는 함수들: strcat, strncat #include #include int main(void) { char str1[20] = "First~"; char str2[20] = "Second"; char str3[20] = "Simple num: "; char str4[20] = "1234567890"; //case1 strcat(str1, str2); puts(str1); //case strncat(str3, str4, 7); puts(str3); return 0; } strcat 함수 호출 시 str2의 문자열이 str1의 문자열 뒤에 덧붙여지는데, 덧붙임이 시작되는 위치는 str1의 널문자 다음이 아니라 널문자가 저장된 위치에서부터 이다. 이렇게 널문자가 저장된 위치에서부터 복사가 ..