这么水的题,唉,三种方法花式过,考的是思维吧?滑稽
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 }