Giter Site home page Giter Site logo

Hi everyone, I would like to add one question which would be a gainer to the bar of practise in array. about algorithms_and_data_structures HOT 3 OPEN

mandliya avatar mandliya commented on May 16, 2024
Hi everyone, I would like to add one question which would be a gainer to the bar of practise in array.

from algorithms_and_data_structures.

Comments (3)

harshit078 avatar harshit078 commented on May 16, 2024

#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.

socialm34 avatar socialm34 commented on May 16, 2024

from algorithms_and_data_structures.

harshit078 avatar harshit078 commented on May 16, 2024

how to work this

using VS code

from algorithms_and_data_structures.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.