LeetCode 342
2024-10-14 17:41:09
Power of Four
Given an integer (signed 32 bits), write a function to check whether it is a power of 4.
Example:
Given num = 16, return true. Given num = 5, return false.
Follow up: Could you solve it without loops/recursion?
/*************************************************************************
> File Name: LeetCode342.c
> Author: Juntaran
> Mail: Jacinthmail@gmail.com
> Created Time: 2016年05月10日 星期二 02时50分00秒
************************************************************************/ /************************************************************************* Power of Four Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:
Given num = 16, return true. Given num = 5, return false. Follow up: Could you solve it without loops/recursion? ************************************************************************/ #include "stdio.h" int isPowerOfFour(int num) {
double tmp = log10(num)/log10();
return tmp == (int)tmp ? : ;
} int main()
{
int n = ;
int ret = isPowerOfFour(n);
printf("%d\n",ret); n = ;
ret = isPowerOfFour(n);
printf("%d\n",ret); return ;
}
最新文章
- 项目中的web api知识总结
- Serena Dimensions 介绍
- ODAC(V9.5.15) 学习笔记(十五)数据离线模式
- ios App优化
- VirtualBox中的Ubuntu没有权限访问共享文件夹/media/sf_bak
- C# 引用类型与值类型的区别
- 创建Material Design风格的Android应用--使用Drawable
- ajax——client访问webservice基本用法
- LayUI分页,LayUI动态分页,LayUI laypage分页,LayUI laypage刷新当前页
- vue 购物车练习
- 安卓开发学习笔记(一):如何用Android Stuidio导出apk文件?
- SpringBoot的国际化使用
- Java基础-对象的内存分配与初始化(一定要明白的干货)
- Linux之ssh登录
- 第二阶段团队冲刺——One
- u3d外部资源加载加密
- 【转】ArcGIS API for Silverlight/WPF 2.1学习笔记(二)
- Eclipse无法查看源码 提示source not found
- python3之Django内置模板标签和过滤器
- C++实现 逆波兰表达式计算问题