Răspuns:
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream f("bac.txt");
int num, p, s;
bool pp(int m )
{
int x=sqrt(m);
if (x*x==m) return true;
else return false;
}
int main()
{
while (f >> num)
{
if (pp(num))
{
p=1; s=1; break;
}
}
while (f>> num)
{
++p;
if (pp(num)) s=p;
}
cout << s;
}
Explicație: