若有定义:intx=7;floata=2.5,b=4.7;则表达式a+x%3*(int)(a+b)%2⼀4的值是()。

2026年09月09日 15:49
有3个网友回答
网友(1):

x%3=7%3=1
(int)(a+b)=(int)(2.5+4.7)=(int)7.2=7
7%2=1
1/4=0
所以a+x%3*(int)(a+b)%2/4=2.5+0=2.5

网友(2):

int x = 7;float a = 2.5,b = 4.7; a + x % 3 * (int)(a + b) % 2 / 4= 2.5 + 7 % 3 * (int)(2.5 + 4.7) % 2 / 4= 2.5 + 7 % 3 * 7 % 2 / 4= 2.5 + 1 * 7 % 2 / 4= 2.5 + 1 / 4= 2.5 + 0= 2.5

网友(3):

#include int main()
{
float exp;
int x=7;
float a=2.5,b=4.7;
exp=a+x%3*(int)(a+b)%2/4;
printf("%f",exp); return 0;}运行结果: