原题传送门->https://ac.nowcoder.com/acm/problem/22003
my blog->https://blog.nowcoder.net/yanhaoyang2106?page=2
题目描述
输入一个整数, 求它的平方根,输出答案往下取整.
输入描述:
输入一个整数n (1 <= n <= 100000)
输出描述:
输出一个整数
示例1
输入
5
输出
2
示例2
输入
16
输出
4
思路
用
#include<cmath>
库里的sqrt()函数求平方根。
代码实现
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int a;
cin>>a;
cout<<(int)sqrt(a);//强转为int型就相当于向下取整
return 0;
}
拜拜