Skip to content

Instantly share code, notes, and snippets.

@m-primo
Created April 25, 2020 14:43
Show Gist options
  • Save m-primo/3ebab1a65c34d7d5c882e39c2ecb1842 to your computer and use it in GitHub Desktop.
Save m-primo/3ebab1a65c34d7d5c882e39c2ecb1842 to your computer and use it in GitHub Desktop.
pascal triangle c++
#include <iostream>
using namespace std;
int a, b;
int main() {
cout << "A: ";
cin >> a;
cout << 1 << " " << endl;
for(int i = 0; i <= a; i++) {
b = 1;
for(int j = 0; j <= i; j++) {
cout << b << " ";
b = b * (i - j) / (j + 1);
}
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment