day3

作者: 今生何求惟你 | 来源:发表于2018-06-13 07:56 被阅读5次

题目:一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?

代码:

#include <stdio.h>

#include <math.h>

main()

{

long int x,y,i;

x=0;

y=0;

for(i=0;i<=100000;i++)

{

x = sqrt(i + 100);

y = sqrt(i + 168);

if (x * x== i + 100&&y * y == i + 168)

printf("The perfect square is %ld",i);

}

return 0;

}

网友评论

    本文标题:day3

    本文链接:https://www.haomeiwen.com/subject/ckkdeftx.html