EXE 2 -- modulo 1000 for the logarithm ......

Source: Internet
Author: User

# 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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.