
C语言double英文意思
#include<iostream.h>voidmain(){inta=7;doublex=2.5,y=4.7;cout<<(x+a%3*(x+y)%2/4)<<endl...
#include <iostream.h>
void main()
{
int a=7;
double x=2.5,y=4.7;
cout<<(x+a%3*(x+y)%2/4)<<endl;
}
结果出现error C2296: '%' : illegal, left operand has type 'double'
题目是:
x+a%3*(x+y)%2/4
设x=2.5,a=7,y=4.7
怎么改?? 展开
void main()
{
int a=7;
double x=2.5,y=4.7;
cout<<(x+a%3*(x+y)%2/4)<<endl;
}
结果出现error C2296: '%' : illegal, left operand has type 'double'
题目是:
x+a%3*(x+y)%2/4
设x=2.5,a=7,y=4.7
怎么改?? 展开
4个回答
展开全部
double是双精度浮点数
error C2296: '%' : illegal, left operand has type 'double'
这句话的意思是说左操作为double类型,不合法
%取余操作不能用非整数进行,所以会不合法
x+a%3*(x+y)%2/4 改为
x+(int)(a%3*(x+y))%2/4
error C2296: '%' : illegal, left operand has type 'double'
这句话的意思是说左操作为double类型,不合法
%取余操作不能用非整数进行,所以会不合法
x+a%3*(x+y)%2/4 改为
x+(int)(a%3*(x+y))%2/4
展开全部
double是双精度浮点数
float是单精度浮点数
%在数值运算中是求余数的。只能对整数运算
(x+y)%2显然是不合法的。
error C2296: '%' : illegal, left operand has type 'double'
错误 C2296: '%': 非法,左操作数类型double
float是单精度浮点数
%在数值运算中是求余数的。只能对整数运算
(x+y)%2显然是不合法的。
error C2296: '%' : illegal, left operand has type 'double'
错误 C2296: '%': 非法,左操作数类型double
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
c中%只能对整数进行运算
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
/ 和%俩头的数字必须为整数 用小数代入算 肯定不行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询