//Points to keep in mind when you want HELP
//Explain what the current prog does, this didnt have syntax errors & had prob in logic
//Put as many comments as possible
//My attempt to help u below
#include <iostream>
using namespace std;
int main()
{
int N, k;
cout<<"Введите кол-во точек: /Enter the No. of Co-ordinates ?? :";
cin>>N;
N=10;
int ch[9][N+1];
for(int i=0 ; i<9; i++){ //when we have the 9 rows in ch ,why init only 4,
//it cuases garbage values to be read when checking quadrants
for(int j=0; j<=N; j++){
ch[i][j]=0;}
}
//int x[N], y[N];
//debug
int x[N]={1,3,-1,-3,-5,2,4,-6,-7,0};
int y[N]={2,4,-2,-4,-6,-3,-5,7,8,0};
//debug
for(int i=0; i<N; i++){
cout<<"Введите абсциссу:(Enter x point /axis??) "<< x[i];
// cin>>x[i];
// cout <<x[i];
cout<<"Введите ординату:(Enter y point /axis??) "<< y[i] ;
//cin>>y[i];
//cout<<y[i];
//ch[i][0] always holds count of # of co-ordinates
//present in the current quadrant {i in [1,2,3,4] }
//check if x,y is part of 1,2,3,4 quadrant
//increment count of co-ord in that quadrant & place it in nn-occupied posisiton
if(x[i] > 0 && y[i] > 0){
int c = ch[1][0];
c++;
ch[1][0]=c;
ch[1][c]=i;
}
else if(x[i] > 0 && y[i] < 0){
int c = ch[4][0];
c++;
ch[4][0]=c;
ch[4][c]=i;
}
else if(x[i] < 0 && y[i] > 0){
int c = ch[2][0];
c++;
ch[2][0]=c;
ch[2][c]=i;
}
else if(x[i] < 0 && y[i] < 0){
int c = ch[3][0];
c++;
ch[3][0]=c;
ch[3][c]=i;
}
else{
int c = ch[0][0];
c++;
ch[0][0]=c;
}
}
/*
int max=0;
for(int i=1; i<4; i++){
for(int j=i+1; j<=4; j++){
if(ch[i][0]>ch[j][0] && ch[i][0]>max){
k=i;
max=ch[i][0];
}else if(ch[i][0]<ch[j][0] && ch[i][0]>max){
k=j;
max=ch[j][0];
}
}
}
*/
//Find the quadrant(k) with maximum co-ordinates(max)
int max=0;
for (int i=1;i<=4;++i){
if (max < ch[i][0])
{
k=i;
max=ch[i][0];
}
}
cout<<"quadrant with maximum co-ordinates present, k="<<k<<endl;
cout<<"Count of co-ordinates present, m="<<max<<endl;
int min=1000;
int A=0;
int Ax=0;
int Ay=0;
int minx=1000;
int miny=1000;
for(int i=1; i<=max; i++){
//Find point closet to 0,0 in quadrant having maximum co-ordinates ??
if(abs(x[ch[k][i]])<minx){
Ax=i;
minx=abs(x[ch[k][i]]);
}if(abs(y[ch[k][i]])<miny){
Ay=i;
miny=abs(y[ch[k][i]]);}
}
if(minx<miny){
A=Ax;
min=minx;
}else{
A=Ay;
min=miny;
}
//By now I dont have patience to understand what below loop is for :( )
for(int i=0; i<max; i++){
if(abs(x[ch[i][Ax]])==(abs(x[ch[k][i]]))){
A=Ax;
}if(abs(y[ch[i][Ay]])==(abs(y[ch[k][i]]))){
A=Ay;
}
}
cout<<"A="<<A<<endl;
cout<<"R="<<min<<endl;
return 0;
}