목차
1. 구현 환경
- Visual Studio 2010
- C++
2. 특징
일반적으로 인터넷에 있는 피보나치수열 구현과 다른점은
int 데이타 사이즈를 넘어가는 큰 경우에 관하여도 계산이 가능합니다.
자세한 사항은 소스코드의 주석과 보고서에 있으니 참고 바랍니다.
[HW1]
HW1.cpp
HW1.vcxproj
HW1.vcxproj.filters
HW1.sln
파일 4
폴더 1
41.5KB
DS_HW1.doc……………………………………………3p
- Visual Studio 2010
- C++
2. 특징
일반적으로 인터넷에 있는 피보나치수열 구현과 다른점은
int 데이타 사이즈를 넘어가는 큰 경우에 관하여도 계산이 가능합니다.
자세한 사항은 소스코드의 주석과 보고서에 있으니 참고 바랍니다.
[HW1]
HW1.cpp
HW1.vcxproj
HW1.vcxproj.filters
HW1.sln
파일 4
폴더 1
41.5KB
DS_HW1.doc……………………………………………3p
본문내용
DS_HW1.doc
Data Structures HW#1
Consider the following (“Fibonatorial”) recursive function:
S(0) = 0
For n>0,
S(n) = S(n-1) + n if n is odd
S(n-1) * n if n is even
Find S(42)
This Problem can solve with recursive algorithm. Because Fibonatorial function calls itself again( S(n) = S(n-1) + n, S(n-1) * n). And I’ll use array because the result is too big that Integer or double(etc..) type can not save that value.
The recursive function needs two fundamental rules.
1. Base Case which can be solved without recursion. S(0)=0 is base case in this problem
2. Making Progress. The recursive function call must always be to case that makes progress toward a base case. We can get S(1) from S(0) in this problem. Also can get S(2),S(3),S(4)…… . And this program prevents error when n is negative value.
#include
#include //This header file is for exit fucntion
const int ARRAY_SIZE = 50; //Array size
int Result[ARRAY_SIZE]; //Save Result to this array
//Fibonatorial function definition. This function returns int type array
int* Fibonatorial(int n){
if(n < 0) { //For n>0
printf(\"Error! Check Input!!\");
exit(1); //exit program
}
if(n == 0) { //Base Case
Result[0] = 0;
return 0; //S(0) = 0
}
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
HW1.cpp
/*Data Strutures Hw1*/
#include
#include //This header file is for exit fucntion
const int ARRAY_SIZE = 50; //Array size
int Result[ARRAY_SIZE]; //Save Result to this array
//Fibonatorial function definition
//This function returns int type array
int* Fibonatorial(int n)
{
if(n < 0) //For n>0
{
printf(\"Error! Check Input!!\");
exit(1); //exit program
}
if(n == 0) //Base Case
{
Result[0] = 0;
return 0; //S(0) = 0
}
Data Structures HW#1
Consider the following (“Fibonatorial”) recursive function:
S(0) = 0
For n>0,
S(n) = S(n-1) + n if n is odd
S(n-1) * n if n is even
Find S(42)
This Problem can solve with recursive algorithm. Because Fibonatorial function calls itself again( S(n) = S(n-1) + n, S(n-1) * n). And I’ll use array because the result is too big that Integer or double(etc..) type can not save that value.
The recursive function needs two fundamental rules.
1. Base Case which can be solved without recursion. S(0)=0 is base case in this problem
2. Making Progress. The recursive function call must always be to case that makes progress toward a base case. We can get S(1) from S(0) in this problem. Also can get S(2),S(3),S(4)…… . And this program prevents error when n is negative value.
#include
#include
const int ARRAY_SIZE = 50; //Array size
int Result[ARRAY_SIZE]; //Save Result to this array
//Fibonatorial function definition. This function returns int type array
int* Fibonatorial(int n){
if(n < 0) { //For n>0
printf(\"Error! Check Input!!\");
exit(1); //exit program
}
if(n == 0) { //Base Case
Result[0] = 0;
return 0; //S(0) = 0
}
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
HW1.cpp
/*Data Strutures Hw1*/
#include
#include
const int ARRAY_SIZE = 50; //Array size
int Result[ARRAY_SIZE]; //Save Result to this array
//Fibonatorial function definition
//This function returns int type array
int* Fibonatorial(int n)
{
if(n < 0) //For n>0
{
printf(\"Error! Check Input!!\");
exit(1); //exit program
}
if(n == 0) //Base Case
{
Result[0] = 0;
return 0; //S(0) = 0
}
추천자료
- (자료구조) 스택을 이용한 후위연산 소스
- (자료구조) 단순 연결리스트를 이용한 삽입 & 삭제 & 검색 소스
- (자료구조) 이중연결리스트를 이용한 삽입 & 삭제 & 검색 소스
- 힙 자료구조를 이용한 상입,제거(특정 토큰에 대해)
- 리스트 자료구조를 이용한 상입,제거(특정 토큰에 대해)
- 자료구조 floyd 알고리즘
- [자료구조]다익스트라 최단 경로 알고리즘
- [자료구조]포인터 배열 삽입 정렬
- [자료구조] 정렬되지 않는 배열 (우선 순위 큐)
- [자료구조] 스택 함수 구현
- [자료구조] 연결 리스트를 이용한 오름차순 정리
- [자료구조] 원형 덱
- SK텔레콤 자본구조발표자료
- C언어 자료구조 Binary Search Tree (이진 탐색 트리)
소개글