509A Maximum in Table

  1. #include <iostream>
  2. using namespace std;
  3. int a, arr[10][10];
  4. int main() {
  5. cin >> a;
  6. for (int i = 0; i < a; i++) {
  7. for (int j = 0; j < a; j++) {
  8. if (i == 0) {
  9. arr[i][j] = 1;
  10. } else if (j == 0) {
  11. arr[i][j] = 1;
  12. } else {
  13. arr[i][j] = arr[i - 1][j] + arr[i][j - 1];
  14.  
  15. }
  16. }
  17. }
  18. cout << arr[a - 1][a - 1];
  19. }

Comments

Popular posts from this blog

Codeforce Problem 1703A. YES or YES?

Aptitude test assistant programmer 2018

1041A. Heist solution