1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Maksim231197 [3]
3 years ago
6

You are given an array of integers "array []" and an input "x". you have to find if there are any two numbers in your array such

that the sum of their square equals to x2 . in other words, you have to find out if there is any pair of i,j such that array[i]2 + array[j]2 = x 2 . if there are such pairs, you should print all such (i,j). otherwise print "there are no such pairs". example: array []: 6, -4, 6, 3, 9, 0, -1, -9, 2, 6 x: 5 you have 1 pair: (-4) 2 + (3) 2 = 5 2 so, your output would be corresponding array indices: (1, 3) note: the array size is 10 and you have to get the elements of the array from
Mathematics
1 answer:
Vesnalui [34]3 years ago
3 0
Given an integer array a, size n, and an input integer value x..  Need to find all pairs of members a[i], a[j] such that (a[i],a[j],x) form a Pythagoras triplet, with x>a[i], a[j].

We need a double loop, the outer loop for a[i], and the inner loop finds a[j].
Here's a pseudocode.

int i, j, x, i2, x2, count=0; 
input x;
x2=x*x;   // economizing on cycles
if x<0 {x=-x};
for i=1 to n-1 {
  if x>=i {      // skip processing the impossible
    i2=i*i;      // economizing on cycles     
    for j=2 to n {
      if x>=j {     // skip processing the impossible
         if i2+j*j==x2 {
            count++;
            print(i,j);
         }
      }
    }
  }
}
if count==0 { print("there are no matched pairs");

It will have a similar complexity as a bubble sort, n^2/2.


You might be interested in
Which number has a 5 that represents a value ten times greater than the value
V125BC [204]
I think it is D 51,324
3 0
3 years ago
Read 2 more answers
What is the solution to the system x-y=-5 and 7x+3y=-75
yan [13]

Answer:

x=-6

y=-11

Step-by-step explanation:

x-y=-5

7x+3y=-75

x=5+y plug that in to the second equation

7(5+y)+3y=-75

35+7y+3y=-75

10y=-75-35

10y=-110

y=-11

plug y into first equation

x+11=5

x=5-11

x=-6

4 0
3 years ago
Round £168.51 to the nearest pound
Nonamiya [84]

The required round of  £168.51 to the nearest pound is £169.

Given that,
To round £168.51 to the nearest pound.

<h3>What is rounding of values?</h3>

The rounding of values is superseding a number with an inexact value that has a more ephemeral, more uncomplicated, or more direct representation.

Here,
£168.51 is given in the question and asked to round is to the nearest pound, since after the decimal the number 51 is closer to the nearest zero i.e. 100,
Implies,
The nearest pound to the  £168.51 is  £169

Thus, the required round of  £168.51 to the nearest pound is £169.

Learn more about round the decimal here;

brainly.com/question/867784

#SPJ1


8 0
2 years ago
Read 2 more answers
a rectangle prism has a volume of 360 in^3 if the height measures 4 in which base measurement would the prism have
k0ka [10]

If a rectanglular prism has a volume of 360 cubic inches and the height is 4 inches, we can figure out the base measurement using the formula for the volume of a rectangular prism.


V = height * base

360 = 4 * base

base = 90 square inches

8 0
4 years ago
Read 2 more answers
Using this relationship between exponents and roots, find the fifth root of 32.
Mariana [72]
I believe it’s 7. Sorry if it’s wrong. Good luck !
3 0
3 years ago
Read 2 more answers
Other questions:
  • There are four large groups of people, each with 1000 members. any two of these groups have 100 members in common. any three of
    15·1 answer
  • How many times does 25 go into 1 million
    5·1 answer
  • Helppppppppppppppppppppppp
    13·1 answer
  • Sweaters cost $39 each. This is $15 more than the price of a cap. Over the season, 725 caps were sold. What was the total sales
    8·1 answer
  • According toThe Humane Society in 2009 33% of US households owned at least one cat and 56% of households who did own cats owned
    12·1 answer
  • Write the equation of a line that passes through (2,-1) and is PARALLEL to y = -3x + 4
    9·1 answer
  • Convert these amounts so they have the same units then express each pair as a ratio in its simplest form A) 5 days to 3 weeks an
    5·1 answer
  • -5(i-30)=-10<br> what does i equal?
    9·1 answer
  • BRAINLIEST
    14·1 answer
  • The ratio of boys to girls in Mr. Hakeem's class is 64. If there are 18 boys, how many girls
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!