間隔内のすべての整数の完全な平方根を出力する必要があるプログラムがあります。今、私はn-the rootに対してそれをしたい.
これが私がやったことですが、fmodで立ち往生しています。
#include <iostream>
#include <math.h>
using namespace std;
int nroot(int, int);
int main()
{
    int p, min, max,i;
    double q;
    cout << "enter min and max of the interval \n";
    cin >> min;
    cin >> max;
    cout << "\n Enter the n-th root \n";
    cin >> p;
    i = min;
    while (i <= max)
    {
        if (fmod((nroot(i, p)), 1.0) == 0)
        {
            cout << nroot(i, p);
        }
        i++;
    }
    return 0;
}
int nroot (int i, int p){
    float q;
    q = (pow(i, (1.0 / p)));
    return q;
}