The instructor assigns assignments to Insus. NET, with the subject as the title.
Interested netizens can also exercise. Currently, the answer provided by Insus. NET is as follows, but the teacher has not read it yet. Therefore, it is not sure whether the answer is correct or the best. It is just for reference.
For the first time, implement the following in the fastest way:
Copy codeThe Code is as follows:
For (int I = 1; I <= 20; I ++)
{
Int j = I * I;
If (j> = 50)
Response. Write (I + "×" + I + "=" + j + "<br/> ");
}
The result is as follows:
After completing the above, Insus. NET immediately remembered that the teacher would not have such a simple problem. Will the teacher need Insus. NET to implement it? If the product is less than 50, the two digits are multiplied without loops, which reduces the performance. Therefore, immediately modify the program just completed:
First, obtain the number of square root of 50 and the number of Double data types. That is to say, a decimal number may appear, and convert it to Integer:
Copy codeThe Code is as follows:
Int min = (int) Math. Sqrt (50 );
In this way, we can know from which Integer the loop starts. But one day, instead of accumulating 50, the square root of the product is 8. If the square of 8 is 64, and the question is more than 64, the correctness starts from 9. The following judgment is true:
Copy codeThe Code is as follows:
If (Math. Pow (min, 2) <50)
Min + = 1;
The final answer to Insus. NET is as follows:
Copy codeThe Code is as follows:
For (int I = min; I <= 20; I ++)
{
Int j = I * I;
Response. Write (I + "×" + I + "=" + j + "<br/> ");
}
The result is the same as the first result.