Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // LTTS - bài toán số cách đi con xe mở rộng
- #include <iostream>
- using namespace std;
- int a[100][100] = {0};
- int b[100][100] = {0};
- int c[100][100] = {0};
- int n;
- int main()
- {
- cout<<"Nhap kich thuoc ban co: "<<endl;
- cin>>n;
- for(int i=0; i<n; i++)
- {
- a[0][i]=1;
- a[i][0]=1;
- b[0][i]=1;
- b[i][0]=1;
- c[0][i]=1;
- c[i][0]=1;
- }
- for(int i=1; i< n; i++)
- {
- for(int j=1; j<n; j++)
- {
- a[i][j]=a[i-1][j]+a[i][j-1];
- }
- }
- for(int i=0; i<n; i++)
- {
- for(int j=0; j<n; j++)
- {
- b[i][j]=b[i-1][j]+b[i][j-1]+a[i][j];
- c[i][j]=c[i-1][j]+c[i][j-1]+b[i][j];
- }
- }
- cout<<"So cach di con xe (khoi lap phuong): "<<c[n-1][n-1]<<endl;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement