error: invalid operands to binary % (have ‘double‘ and ‘int‘)取模mod %
此处出现错误:
因为%不可以用于浮点型(double,float类型),只能用于整型(int类型)
可以强制类型转换,将浮点型强制转换为整型,解决此问题
double b = (int) floor(x/10)%10;
double c = (int) floor(x/100)%10;
一段判断三位数是否为回文数的代码:
#include<stdio.h>
#include<math.h>
int main()
{int x = 0;scanf("%d\n",&x);int a = x%10;double b = (int) floor(x/10)%10;double c = (int) floor(x/100)%10;int t = a*100+b*10+c;if(x==t){printf("x是回文数");}else{printf("x不是回文数");}return 0;
}
error: invalid operands to binary % (have ‘double‘ and ‘int‘)取模mod %相关推荐
- [Error] invalid operands of types ‘float‘ and ‘float‘ to binary ‘operator%‘
是因为求余运算符%要求左边的数是整数,但是把一个 float 类型的数放在%左边进行运算,就会报以上 错误 .所以要么转型(int)a,但是必须是a本身是整数的情况或者说符合题目要求只需要整型部分,不 ...
- reorg_cls_centerness.cpp:4658:74: error: invalid conversion from ‘int’ to ‘PyObject* {aka _object*}’
运行python rotation_setup.py build时,报错: rotation/reorg_cls_centerness.cpp: In function 'int __Pyx_Init ...
- error: invalid new-expression of abstract class type 'Rectangle'
class GeometricObject { --virtual bool hit(const Ray& ray, double& t, ShadeRec& s) const ...
- OTS parsing error: invalid version tag woff和ttf文件被Filter拦截
从服务器下载的字体文件放在本地,执行无法展示iconfont,浏览器控制台报出 Failed to decode downloaded font: http://127.0.0.1:8080/mhr/ ...
- ruby环境sass编译中文出现Syntax error: Invalid GBK character错误解决方法
sass文件编译时候使用ruby环境,无论是界面化的koala工具还是命令行模式的都无法通过,真是令人烦恼. 容易出现中文注释时候无法编译通过,或者出现乱码,找了几天的解决方法终于解决了. 这个问题的 ...
- 【笔记】Error while loading PyV8 binary: exit code 1解决方法
[笔记]Error while loading PyV8 binary: exit code 1解决方法 参考文章: (1)[笔记]Error while loading PyV8 binary: e ...
- cuda error invalid argument
用pytorch训练时报的错 在loss.backward时报错 估计应该是loss出现了异常值. 网上其他答案: 问题: RuntimeError: CUDA error: invalid conf ...
- runtime error: invalid memory address or nil pointer dereference
runtime error: invalid memory address or nil pointer dereference 解决方法: tcallback((unsigned char*)pac ...
- Package CJK Error: Invalid character code. 问题解决方法--xelatex和pdflatex编译的转换
Package CJK Error: Invalid character code. 问题解决方法--xelatex和pdflatex编译的转换 解决方法:添加格式说明信息 将下面语句: \docum ...
最新文章
- oracle 无效索引
- 烧了微软10000张GPU,这伙人铁了心要砸大家的饭碗
- Sam Hartman 当选 Debian 社区领导人
- SharePoint 开发TimerJob 介绍
- Java Platform SE 8 中文文档
- pyton random 模块
- css3 flex布局九宫格,css3最全flex布局结构整理
- 免费赠送2本新书《iOS程序员面试笔试真题与解析》
- 批量word转pdf
- Hexo NexT主题自定义背景图片
- fatal: Authentication failed for ‘https://github.com/xxx/xxx.git/’解决方法
- 常用web前端UI组件库
- GIS空间分析 缓冲区分析与叠加分析1 选址分析(市区择房)
- 极简主义、人工智能与Readhub的产品哲学
- python web py入门(12)- 实现用户登录论坛
- css样式单位px,em,pt,ex,pc,in,mm,cm详解
- python中排序从小到大_python怎么从小到大排列
- JavaScript对象复习
- (概率/dp)P2059 [JLOI2013]卡牌游戏
- CC2642R 蓝牙MCU芯片的学习