【发布时间】:2021-12-30 16:40:07
【问题描述】:
在c++ 中,以下代码显示错误:
expression must have integral or unscoped enum type
illegal left operand has type 'double'
是否可以在不需要使用fmod的情况下更正它?
# include <iostream>
using namespace std;
int main()
{
int x = 5, y = 6, z = 4;
float w = 3.5, c;
c = (y + w - 0.5) % x * y; // here is the error
cout << "c = " << c << endl;
return 0;
}
【问题讨论】:
-
先切换到
int? -
您能评论一下您希望
(y + w - 0.5) % x * y做什么吗? -
我做了,编译器输出9,计算器显示24!
-
您认为
%操作员是做什么的? -
标签: c++ visual-studio