#include <iostream.h>
class TriNum{
int a[100];
int n;
int p, q;
public:
TriNum(int n=0, int p=0, int q=0){ this->n = n; this->p = p; this->q = q;}//这里this->n = n; this->p = p; this->q = q代表什么呀?
void process();
void Print();
friend istream& operator>>(istream& istr, TriNum&);
};
istream& operator>>(istream& istr, TriNum& tri)//这里是什么意思为什么要这样定义?为什么要定义为友员函数呀
{
cout << "请输入求值范围(p, q):";
cin >> tri.p >> tri.q;
while( tri.p<100 || tri.q < 100 || tri.p>999 || tri.q > 999 || tri.p>tri.q )
{
cout << "请输入求值范围(p, q):";
cin >> tri.p >> tri.q;
}
return istr;//这里返回的是什么值?
}
void TriNum::Print()
{
cout << "个数:" << n;
cout << "满足条件的数有:" ;
for( int i=0; i<n; i++) cout << " " << a[i] ;
cout << endl;
}
void TriNum::process()
{
int s, t1, t2, t3;
for( int i=p; i<=q; i++)
{
s = i / 11;
t3 = i/100; t2 = (i % 100)/10; t1 = i % 10;
if( s == t3*t3 + t2*t2 + t1*t1 )
{
a[n] = i;
n++;
}
}
}
void main()
{
TriNum tri;
cin >> tri;
tri.process();
tri.Print();
}