• C++-蓝桥杯-振兴中华[2013真题][水题][dp/递归]


    这么水的题,唉,三种方法花式过,考的是思维吧?滑稽

     1 #include <iostream>
     2 using namespace std;
     3 int dp[10][10];
     4 int f(int x,int y){
     5     if(x==1||y==1)return 1;
     6     return f(x-1,y)+f(x,y-1);
     7 }
     8 void solution1(){cout<<"35"<<endl;}//经观察手玩得出
     9 void solution2(){cout<<f(4,5)<<endl;}
    10 void solution3(){
    11     for(int i=1;i<=4;i++)
    12         for(int j=1;j<=5;j++)
    13                 dp[i][j]=(i==1&&j==1)?1:dp[i-1][j]+dp[i][j-1];
    14     cout<<dp[4][5]<<endl;
    15 }
    16 int main(){
    17     solution1();
    18     solution2();
    19     solution3();
    20     return 0;
    21 } 
  • 相关阅读:
    常用英语1000句
    TXT EXPLORER
    窗体美化
    C++ Code_StatusBar
    C++ Code_Slider
    C++ Code_ScrollBar
    C++ Code_ImageList
    C++ Code_HotKey
    C++ Code_animateCtrl
    C++ CheckMenuItem
  • 原文地址:https://www.cnblogs.com/JasonCow/p/12397439.html
Copyright © 2020-2023  润新知