Comments (3)
#include
using namespace std;
// Function to generate Special Triangle
void printTriangle(int A[] , int n)
{
// Base case
if (n < 1)
return;
// Creating new array which contains the
// Sum of consecutive elements in
// the array passes as parameter.
int temp[n - 1];
for (int i = 0; i < n - 1; i++)
{
int x = A[i] + A[i + 1];
temp[i] = x;
}
// Make a recursive call and pass
// the newly created array
printTriangle(temp, n - 1);
// Print current array in the end so
// that smaller arrays are printed first
for (int i = 0; i < n ; i++)
{
if(i == n - 1)
cout << A[i] << " ";
else
cout << A[i] << ", ";
}
cout << endl;
}
// Driver function
int main()
{
int A[] = { 1, 2, 3, 4, 5 };
int n = sizeof(A) / sizeof(A[0]);
printTriangle(A, n);
}
from algorithms_and_data_structures.
from algorithms_and_data_structures.
how to work this
…
using VS code
from algorithms_and_data_structures.
Related Issues (20)
- 3 sum problemm leetcode HOT 5
- wrong heap sort algorithm HOT 4
- Shouldn't we update (head.prev).next to the new Node?
- Added kadane HOT 5
- algorithms_and_data_structures/stack_problems/ HOT 1
- word_pattern.cpp compiler error
- Hi!, I would like to add a problem in leetcode section . HOT 2
- C++ problems
- Algorithm HOT 2
- To watch
- Find Duplicate HOT 5
- i would like to add problem number to all the file names in the leetcode section HOT 1
- Remove CmakeCache.txt
- The root node should be of value 16 after compiling the code HOT 2
- Error in swapNodesWithoutSwappingData.cpp HOT 3
- Error in binarySearchTree.h HOT 1
- memory leak in removeDuplicatesFromSortedList.cpp HOT 1
- Algorithm
- Algorithms_and_data_structures
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from algorithms_and_data_structures.