File tree Expand file tree Collapse file tree 3 files changed +51
-1
lines changed
Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ *@author: profgrammer
3+ *@date: 09-01-2019
4+ */
5+
6+ #include < bits/stdc++.h>
7+ using namespace std ;
8+
9+ int ncr (int n, int r){
10+ if (n < r || n < 0 || r < 0 ) return 0 ;
11+ if (n == r || r == 0 ) return 1 ;
12+ return ncr (n-1 ,r) + ncr (n-1 , r-1 );
13+ }
14+
15+ int main () {
16+ int n;
17+ cin>>n;
18+ for (int i = 0 ;i <= n;i++){
19+ for (int j = 0 ;j <= i;j++) cout<<ncr (i,j)<<" " ;
20+ cout<<endl;
21+ }
22+ }
Original file line number Diff line number Diff line change @@ -82,6 +82,33 @@ int main(){
8282}
8383```
8484
85+ ## [C++ Solution by @profgrammer](./C++/profgrammer_pascal.cpp)
86+
87+ ```cpp
88+ /*
89+ *@author: profgrammer
90+ *@date: 09-01-2019
91+ */
92+
93+ #include <bits/stdc++.h>
94+ using namespace std;
95+
96+ int ncr(int n, int r){
97+ if(n < r || n < 0 || r < 0) return 0;
98+ if(n == r || r == 0) return 1;
99+ return ncr(n-1,r) + ncr(n-1, r-1);
100+ }
101+
102+ int main() {
103+ int n;
104+ cin>>n;
105+ for(int i = 0;i <= n;i++){
106+ for(int j = 0;j <= i;j++) cout<<ncr(i,j)<<" ";
107+ cout<<endl;
108+ }
109+ }
110+ ```
111+
85112## Python Implementation
86113
87114### [ Solution] (./Python/pascal.py)
@@ -189,4 +216,5 @@ def main():
189216 print (f' Pascal triangle cannot have {num} rows' )
190217
191218main()
219+
192220```
Original file line number Diff line number Diff line change @@ -288,7 +288,7 @@ int main() {
288288 getline(cin, first);
289289 getline(cin, second);
290290 cout << "The Levenshtein distance between \"" << first << "\" and \"" << second << "\" is: " << dist(first, second) << endl;
291- }
291+ }
292292```
293293
294294### C Implementation
You can’t perform that action at this time.
0 commit comments