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 4weekends:
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; }