What's wrong? Not all tests pass.

Linear array A contains 2 * N elements whose values ​​are given by the following formula a [i]: = 10 * sin (N + i * i). The array elements are numbered from one.

Find the number of points located outside the rectangle given by the coordinates of the vertices of one of the diagonals, if the values ​​of the elements A [1] and A [2] are the coordinates of the first point, the elements A [3] and A [4] are the second point, etc. The sides of the rectangle are parallel to the corresponding axes of the coordinate system.

Sample input:

54 -8 10 7 4 

weekends: 41

 #include <iostream> #include <cmath> #include <algorithm> using namespace std; int main() { int n,size,x1,x2,y1,y2,x_1,x_2,y_1,y_2,q=0; cin >> n >> x_1 >> y_1 >> x_2 >> y_2; x1=min(x_1,x_2); x2=max(x_1,x_2); y1=min(y_1,y_2); y2=max(y_1,y_2); size=2*n+1; float arr[size]; for (int i=1;i<size;i++) { arr[i]=10*sin(n+i*i); } for (int i=1;i<size;i+=2) { if (arr[i] <= x1 || arr[i] >= x2 || arr[i+1] <= y1 || arr[i+q] >= y2) q++; } cout << q; return 0; } 

Closed due to the fact that off-topic participants Kromster , MSDN.WhiteKnight , Suvitruf , freim , aleksandr barakin February 1 at 13:49 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Kromster, Suvitruf, freim
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • This question should be closed, because it should be addressed to the author of the tests that “do not pass” - aleksandr barakin February

1 answer 1

Change the condition arr[i+q] to arr[i+1] .

  • one
    Why did you write this? - Igor
  • one
    @Max Why did you, in that case, accept that answer? - Igor
  • one
    @Max So from that answer, you didn't learn anything. Sadly - Igor
  • one
    @Max And signs = from comparisons, apparently, should still be removed. - Igor
  • one
    @Max What it is about. Read both answers again. (We did not agree with AnT.) Take your time. Think about it. - Igor