[자료구조] 피보나치수열 - int 데이타 사이즈를 넘어가는 결과값 계산 프로그램
본 자료는 미리보기를 지원하지 않습니다.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
해당 자료는 2페이지 까지만 미리보기를 제공합니다.
2페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

[자료구조] 피보나치수열 - int 데이타 사이즈를 넘어가는 결과값 계산 프로그램 에 대한 보고서 자료입니다.

목차

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

본문내용

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
    }
  • 가격1,300
  • 페이지수7페이지
  • 등록일2013.08.04
  • 저작시기2007.3
  • 파일형식압축파일(zip)
  • 자료번호#869309
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니