일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
- MST
- 플로이드-워셜
- DFS
- 수학
- join
- 시뮬레이션
- 브루트포스
- 누적합
- 해시
- BFS
- 에라토스테네스의 체
- GROUP BY
- 다이나믹 프로그래밍
- 투포인터
- 백트래킹
- 재귀
- 트리
- 크루스칼
- 다익스트라
- DP
- 그래프 이론
- 다이나믹프로그래밍
- 그리디
- 구현
- 우선순위큐
- 서브쿼리
- 다시
- 그래프 탐색
- 분할정복
- 자료구조
- Today
- Total
목록전공/C (20)
기록하고 까먹지 말기

array size를 입력받고 array 생성, element를 입력받은 후 그 값들을 출력하는 프로그램이다. #include #define MAX_SIZE 1000 // Maximum array size int main(){ int arr[MAX_SIZE]; // declare array int n, i; // inputs size of array from user printf("Enter size of array: "); scanf("%d", &n); // inputs elements in the array printf("Enter %d elements in the array : ", n); for(i=0; i

이번 중간고사때 있었던 코딩테스트다 중간고사이기도 하고 개념이 쉬운 개념만 나왔기 때문에 문제는 전반적으로 어렵지는 않았다. 제한시간도 1시간밖에 되지 않았고 다 푸니까 30분정도 남았어서 지루하게 기다렸던 기억이 있다. #include int main(){ int time = 0; // input seconds from user int h, m, s; // declaring variables printf("Q) seconds? "); // asking and enter a time scanf("%d", &time); // calculating hour, minute and seconds h = time / 3600; time %= 3600; m = time / 60; time %= 60; s = tim..

함수를 통한 swap을 구현하는 문제이다. #include int x, y = 0; // declare x, y with global variable void swap(int n1, int n2){ // swapping x = n2; y = n1; return; } int main(){ // input value of x, y(global variable) printf("Enter Value of x\n"); scanf("%d", &x); printf("Enter Value of y\n"); scanf("%d", &y); swap(x, y); // using function printf("After Swapping: x = %d, y = %d\n", x, y); // printing output retu..

C에서 가장 많이 사용되는 것 중 하나인 Function이다. 주로 function을 통한 연산이나 재귀를 통해 문제를 해결하는 것이 주를 이루었다. 개인적으로 하노이의 탑이 나오지 않아 아쉽지만 처음 함수를 배웠을 때 리턴타입의 개념이 확실하게 정립되지 않아 꽤나 어려웠던 기억이 있었다. 수를 입력받은 후 세제곱을 출력하는 프로그램이다. #include double Cube(int n){ return n * n * n; // calculating and returning the result } int main(){ int n; printf("Enter any number: "); scanf("%d", &n); // getting input number from user printf("Cube of %d..

일반적으로 많이 나오는 구구단 출력 프로그램이다. #include int main(){ int n=0; int i=0; printf("Enter number to print table: "); scanf("%d", &n); // inputs number for(i=1; i 0); // repeats until remain value of n is larger than 0 printf("Total digits: %d", result); // print result return 0; } 0이 나올때까지 수를 입력받고 0이 나온 시점에서의 모든 수의 합을 구하는 프로그램이다. while문과 if문을 혼용할 수도 있고 while문만을 가지고 해결 가능하다. 더 확실히 하기 위해 나는 if~break를 활용하여 ..

c에서 가장 많이 사용되는 반복문인 for, while문을 활용하여 해결하는 과제이다. 어디서 먼저 시작되는지, 어디서 끝나야 하는지를 확실하게 파악했기 때문에 큰 어려움은 없었다. 알파벳 소문자를 for문, while문을 통해 해결하는 문제다. c의 경우 for(int i=0; i

입력받은 점수들의 퍼센트를 구하고 if, else문을 통해 해당 점수들의 등급을 매기는 문제이다. for문을 통해 5개의 점수를 입력받고 평균및 퍼센트를 구한 후 case에 따라 grade를 출력하면 된다. #include int main(){ int n1, n2, n3, n4, n5; char g; printf("Enter five subjects marks: "); scanf("%d %d %d %d %d", &n1, &n2, &n3, &n4, &n5); // inputs 5 marks float total = (float)(n1+n2+n3+n4+n5)/5; // calculating total percentages printf("Percentage = %.2f\n", total); // getting..

if~else문, 그리고 switch문을 통해 해결하는 문제가 주를 이루었다. 개인적으로 switch는.... 너무 귀찮았다. if~else문을 통해 입력받은 수가 양수인지, 음수인지, 혹은 0인지를 판별, 결과를 출력하는 프로그램이다. if, else if, else를 활용하여 간단하게 해결 가능하다. #include int main(){ int n; printf("Enter any number: "); scanf("%d", &n); // inputs the number from user // check whether the number is positive or not or zero then prints output if(n > 0){ printf("Number is POSITIVE\n"); } el..