Computer Science, asked by maroofmushtaq01, 6 months ago

ant sumt 10) = new int[4] [41:
for (int k = 0; k < 4: k++) sum[k]0) = 1:
for (int k = 0; k < 4; k++) sum|01|k) =
for (int m= 1; m < 4; m++)
for (int n = 1; n < 4; n++)
sum[m] [n] = sum[m-1] [n 1] + summin-1
for (int n = 1; n < 4; n++)
System.out.print (sum[3] (n) + **)​

Answers

Answered by shashidubey1119
1

Answer:

/ C++ program for naive solution to

// print all combination of 4 elements

// in A[] with sum equal to X 

#include <bits/stdc++.h>

using namespace std;

  

/* A naive solution to print all combination 

of 4 elements in A[]with sum equal to X */

void findFourElements(int A[], int n, int X)

{

      

// Fix the first element and find other three

for (int i = 0; i < n - 3; i++)

{

    // Fix the second element and find other two

    for (int j = i + 1; j < n - 2; j++)

    {

          

        // Fix the third element and find the fourth

        for (int k = j + 1; k < n - 1; k++)

        {

            // find the fourth

            for (int l = k + 1; l < n; l++)

            if (A[i] + A[j] + A[k] + A[l] == X)

                cout << A[i] <<", " << A[j] 

                     << ", " << A[k] << ", " << A[l];

Similar questions