博客
关于我
#Leetcode# 69. Sqrt(x)
阅读量:797 次
发布时间:2023-04-04

本文共 976 字,大约阅读时间需要 3 分钟。

Implement int sqrt(int x).

Compute and return the square root of x, where x is guaranteed to be a non-negative integer.

Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned.

Example 1:

Input: 4
Output: 2

Example 2:

Input: 8
Output: 2

Explanation: The square root of 8 is 2.82842..., and since the decimal part is truncated, 2 is returned.

代码:

class Solution {public:    int mySqrt(int x) {        int ans = (int)sqrt(x);        return ans;    }}

以上HTML代码经过优化,去除了多余的div标签和不必要的结构,保持了内容的完整性和可读性。代码块通过<div class="cnblogs_Highlighter">包裹,方便与其他样式进行区分。文章内容经过重新组织,使其更加简洁明了,同时保留了技术细节和示例信息。

转载地址:http://tnrfk.baihongyu.com/

你可能感兴趣的文章
MySQL 高可用性之keepalived+mysql双主
查看>>
MySql-2019-4-21-复习
查看>>
mysql-connector-java各种版本下载地址
查看>>
mysql-group_concat
查看>>
MySQL-redo日志
查看>>
MySQL-【1】配置
查看>>
MySQL-【4】基本操作
查看>>
Mysql-丢失更新
查看>>
Mysql-事务阻塞
查看>>
Mysql-存储引擎
查看>>
mysql-开启慢查询&所有操作记录日志
查看>>
MySQL-数据目录
查看>>
MySQL-数据页的结构
查看>>
MySQL-架构篇
查看>>
MySQL-索引的分类(聚簇索引、二级索引、联合索引)
查看>>
Mysql-触发器及创建触发器失败原因
查看>>
MySQL-连接
查看>>
mysql-递归查询(二)
查看>>
MySQL5.1安装
查看>>
mysql5.5和5.6版本间的坑
查看>>