首页 文章

完美的正方形,包括两个终值

提问于
浏览
2

我试图获得两个值之间的所有完美正方形(包括两个) . 我尝试了以下代码,它给出了计数,不包括最终值 .

CIN >> A >> B; N =(INT)SQRT(b)中-sqrt(a)的

How can i get the count of perfect squares including the end values?

1 回答

  • 0

    只需为您的逻辑添加边界条件

    如何钓鱼 - 伪代码在这里

    • n以0开头

    • 如果是|| b是完美的正方形,n

    • n =(int)(sqrt(b) - sqrt(a))

    • 返回n

    鱼 - here is the answer

相关问题