IT/[Everyday]Coding39 [이항계수]경우의 수 구하는 프로그램 n개에서 m개를 뽑는 경우의 수 구하는 프로그램(단점 수가 커지면 오류가 난다 ex 50C20 같은 경우) #include #include using namespace std; int numOfCross(int n, int m){ int denom=1, codenom=1; int result; if(n 2014. 12. 19. 팩토리얼 계산 2가지 방법 for문사용#include #include using namespace std;int main(){ int getNum=0; int result=1; cin >> getNum; for(int j=1; j 2014. 12. 19. queue 구현 #include #include using namespace std;#define QUEUE_C 8int queue[QUEUE_C];int head = 0;int tail = -1;int queue_size = 0; void enqueue(int n){ if(queue_size == QUEUE_C){ cout 0) { enqueue(number); }else if(number == 0){ r = dequeue(); cout 2014. 12. 19. 배열 회전 배열 arr[]과 위치 s, t가 있을 때, arr[s], arr[s+1], ..., arr[t-1]을 오른쪽으로 한 칸씩 이동하고, arr[t]는 arr[s]로 복사하는 것을 1만큼 오른쪽으로 회전시킨다. 예를 들어 s=2, t=6이면 길이가 8인 아래 배열은 그림과 같이 바뀐다.0 1 s=2 3 4 5t= 6 7 1 23 4 56 7 8 0 1 2 3 4 5 6 7 12 734 5 6 8 #include #include using namespace std; void right_rotatie(int arr[], int s, int t){ int temp; temp = arr[t]; for(t; t>=s; t--) { arr[t]=arr[t-1]; } arr[s]=temp;} int main(){ int.. 2014. 12. 19. 이전 1 ··· 4 5 6 7 8 9 10 다음 반응형