본문 바로가기

C/C++

[C/C++] 스택(배열) CodeColored By Color Scripter™123456789101112131415161718192021222324252627282930313233343536#include #define MAX 2int stack[MAX];int top = -1; void push(int value){ if (top >= MAX - 1) { printf("Error\n"); return; } stack[++top] = value;} int pop(void){ if (top 더보기
[C/C++](유클리드 호제법)간단한 최대공약수, 최소공배수(GCD,,LCM) 소스 코드 Code Colored By Color Scripter™1234567891011int gcd(int a, int b){ if (b == 0) return a; gcd(b, a%b);} int lcm(int a, int b){ return (a*b) / gcd(a, b);} 더보기
[C/C++]0.5 더하여 반올림하기 Explanation 0.5를 더하면 float가 되고, 값을 int형 변수에 넣어주면 int로 자동 다운 캐스팅되며 반올림이 일어난다. Code Colored By Color Scripter™123456int main(){ int n; n = 0.5 + (float)8 / 3; printf("%d", n);} 더보기
[C/C++]버블 정렬(Bubble sort) Code Colored By Color Scripter™123456789101112for (int i = 1; i 더보기
[C/C++]몇 줄 안되는 퀵 정렬(Quick sort) Code Colored By Color Scripter™12345678910111213141516171819#define SWAP(a,b,c) ((c) = (a),(a) = (b),(b) = (c)) void quicksort(int v[], int n) { int i, last;int temp; if (n 더보기
[문제해결]an error occurred while creating or opening the c++ browsing database file 컴퓨터 포맷 후 새로 설치한 VS2013 그러나 코딩을 하려는데 뭔가 한 박자씩 느리고, 에디터를 종료시키니 종료되기 전에 이런 오류 메시지를 발생했다. 'an error occurred while creating or opening the c++ browsing database file....' 내용은 간략히 ...sdf 파일을 여는데 문제가 생겼고, IntelliSense와 Browsing information을 C++프로젝트에서 사용할 수 없다는 얘기다. 간단히 위 이미지의 두번째 문단에 나온 것 처럼 SQL Server Compact를 설치하여 쉽게 해결하였다. 더보기
[C][Algorithm]The logic to get the divisors and the codes in C - Here we go Let's get the divisors of n! 1) Basic - Divide n in i ( i substitutes from 1 to n). If the remainder is 0, the i would be a divisor. 123456789101112#include int main(void){ int i,n; scanf("%d", &n); for(i=1; i 더보기