c语言入门经典100道程序编辑(国外英文资料)
c语言入门经典100道程序编辑(国外英文资料)
Problem: an integer, plus 100 is a perfect square, plus 168 is another perfect square. What is the number?
Program analysis: judgment within 100000, the first number plus 100 before prescribing, then the number plus 268 before prescribing, if the results of prescribing satisfy the following conditions, which is the result. See the analysis:
Program source code:
H # include "math."
The main ()
{
Long int I, x, y, z;
For (I = 1; I < 100000; I + +)
{x = SQRT (I + 100); / * x is equal to the result after 100
Y = SQRT (I + 268); / * y is equal to the result after 168
If (x * x = = = = I + 100 & y = = = I + 268)
/ * if the square root of a number is equal to that number, this means that this number is perfect square
Printf (\ n % ld \ n, I);
}
}
Question: 1, 2, 3, 4 Numbers, how many different and no duplicate digits can be made? How much is?
Program analysis: in the hundreds, the tens place, the ones digit is 1, 2, 3, 4. Make up all the permutations and then remove the ones that don't meet the criteria.
Program source code:
The main ()
{
Int I, j, k;
Printf (" \ n ");
For (I = 1; I < 5; I + +) / * below is the triple loop * /
For (j = 1; j < 5; j + +)
(k = 1; k < 5; k + +)
{
If (I! = k)/(= k)/(= k)/(= k)/(= k)/(= k)/(= k)/(= k)/(= k)/(= k)/(= k)/(= k)/(= k)/(= k)/(= k) /
Printf (" % d, % d, % d \ n ", I, j, k);
}
}
Problem: an integer, plus 100 is a perfect square, plus 168 is another perfect square. What is the number?
Program analysis: judgment within 100000, the first number plus 100 before prescribing, then the number plus 268 before prescribing, if the results of prescribing satisfy the following conditions, which is the result. See the analysis:
Program source code:
H # include "math."
The main ()
{
Long int I, x, y, z;
For (I = 1; I < 100000; I + +)
{x = SQRT (I + 100); / * x is equal to the result after 100
Y = SQRT (I + 268); / * y is equal to the result after 168
If (x * x = = = = I + 100 & y = = = I + 268)
/ * if the square root of a nu