close

路徑問題

#include<iostream>
using namespace std;

#define M 10
#define N 10

int t[M+1][N+1];

int main()
{
  int i, j, m, n;
  int p;

  for(i=0; i<=M; i++)
      for(j=0; j<=N; j++)
          t[i][j]= (i*j ==0) ? 1 : 0;

  for(i=1; i<=M; i++)
      for(j=1; j<=N; j++)
          t[i][j] = t[i-1][j-1] + t[i-1][j] + t[i][j-1];

  while(scanf("%d %d", &m, &n)==2)
      printf("%d\n----------\n",t[m][n]);

  system("pause");
  return 0;
}


path   


arrow
arrow
    全站熱搜

    LawlietMoon 發表在 痞客邦 留言(1) 人氣()