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
A train travels 250 miles at a constant speed (x), in miles per hour.
Sedaia [141]
250 = 5 x is the equation you can use
4 0
3 years ago
Read 2 more answers
Find and correct the error of the following factor.
pshichka [43]

3x² + xy2 – 3xy-y? >> 3x² - xy - y

line 1: = (3x² + xy2)+(-3xy – y?)

ANS 3x² - xy - y 《Correct》

line 2: = x(3x + y2) - y(3x – y2)

ANS 3x² - xy +2y²

line 3: = (x-y) (3x +y?)

ANS 3x² - 2xy - y²

If it incorrect, I'm sorry.

3 0
4 years ago
How are expressions 1/4 of 12 and 12 divided by 4
Radda [10]
0 is the awnser —————-1————-
8 0
3 years ago
What is the surface area of the figure?
anyanavicka [17]

Answer:

24 is what I got

Just find the are of each shape and add the answers together to get the total area of the figure

7 0
4 years ago
Read 2 more answers
According to Cavalieri’s Principle, if a cone and a pyramid have the same height, which of the following answer choices is true?
Elodia [21]

Answer:

brainly.com/question/2855114

answers the same question, I had the same question as well.

4 0
4 years ago
Other questions:
  • A:b=7.2
    8·1 answer
  • A recipe calls for 2/2/4 cups of rainsins but Julie only has a 1/4 cups how many 1/4 cups does Juile need to measure out 2/2/4 c
    15·1 answer
  • What is the value of m?
    6·2 answers
  • What is -45 degrees 5 times colder
    10·2 answers
  • Porfaaaaa ayudaaa necesito la respuesta rapido plsss
    12·1 answer
  • 18. Which number rounds to 0.94 when rounded to the nearesthundredth?
    13·2 answers
  • How can a baseball team win a game without a single man crossing home plate
    7·1 answer
  • A cone and a cylinder have the same base and height, as shown below. A cone is inside of a cylinder with same base and height. T
    15·1 answer
  • 11) Tickets to a concert cost either $15 or
    10·1 answer
  • Find the midpoint of points A(-9, -3) and B(1, 7) graphically.<br> Plot the line segment AB
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!