# Include <iostream>
Using namespace STD;
Int num = 0; // count the number of iterations globally
Int Q [100]; // array of the result of each iteration
Typedef struct
{
Int B;
Int S;
Int g;
} Ctype;
Int quwei (INT number, ctype State [])
{
Number = Number % 1000;
State [num]. B = Number/100; // hundreds of digits
State [num]. S = (number/10) % 10; // ten
State [num]. G = Number % 10; // bit
Int q = Q [num] = State [num]. B * State [num]. B * State [num]. B + State [num]. S * State [num]. S + State [num]. g;
Return Q;
}
Bool confilict (int q [], int q)
{
For (INT I = 0; I <num-1; I ++)
{
If (q = Q [I])
Return true;
}
Return false;
}
int main ()
{< br> int q = 0;
ctype State [100];
int number;
char c = 'y';
while (C = 'y ')
{< br> cout CIN> Number;
q = quwei (number, state); // obtain Q [0]
num ++;
while (! Confilict (Q, q)
{< br> q = quwei (Q, State);
num ++;
}< br> cout <"iterations:" cout <"the intermediate result of each iteration is: " for (Int J = 0; j cout <"Q [" cout <"Again: Y/n? " num = 0;
CIN> C;
}< br> return 0;
}