Take the ladder _ Fepolaci

Source: Internet
Author: User

There is a ladder, each can only walk 1 steps or 2 steps, the ladder from 0 to start counting, now enter the ladder order, to find a total number of ways to go.

Since each can only walk 1 steps or 2 steps, so go to the 3rd order, not from the 1th step, is to go from the 2nd step. Therefore, the 3rd-order method is the 1th-order method plus the 2nd-order method of the same way. So the analogy.

1 #define_crt_secure_no_warnings2 3#include <stdio.h>4#include <windows.h>5 6 DoubleTencent (intn);//if the value is too large, you need to use a double type7 8 Main ()9 {Ten     intN; One  Ascanf"%d", &n); -  -printf"%f", Tencent (N)); the  -System"Pause"); - } -  + DoubleTencent (intN) - { +     if(n = =1)//1th-order, 1-way approach A     { at         return 1; -     } -     Else if(n = =2)//2nd-order, 2-way approach -     { -         return 2; -     } in     Else -     { to         returnTencent (N-1) + Tencent (N-2); +     } -}

Take the ladder _ Fepolaci

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.