I am writing a program for statistics, and I need to calculate the quartiles. The problem is that the installation of else going on all the time, and it is not clear why the code does not work:
In my case, n=130 and on i=2 and i=4 should work
tmp == (ceil(tmp)-1) round to larger and subtract one
void KvartilC(vector<int>&X,float n) { for(int i=1;i<=4;i++) { float tmp = (i*n) / 4; // если число целое то подходит, если нет то //квартиля нет if (tmp == (ceil(tmp)-1)) // проверка на целочисельность { cout <<"Qvartil_"<<i<<" : "<< X[tmp]<< endl; } else { cout << "Ne isnuje Qvartila_"<<i<< endl; } } }
(i*n)%4==0or(i*n)&3==0- MBo