c语言题中 (i & 1) (y += i*i*i) :(x += i*i);句话什么意思#include int main(void){unsigned int m,n,i,x,y;while (scanf("%u%u",&m,&n) = EOF){if (m > n){i = n;n = m;m = i;}x = y = 0;for (i = m ; i

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/22 03:43:01
c语言题中(i&1)(y+=i*i*i):(x+=i*i);句话什么意思#includeintmain(void){unsignedintm,n,i,x,y;while(scanf("%u%u",&m

c语言题中 (i & 1) (y += i*i*i) :(x += i*i);句话什么意思#include int main(void){unsigned int m,n,i,x,y;while (scanf("%u%u",&m,&n) = EOF){if (m > n){i = n;n = m;m = i;}x = y = 0;for (i = m ; i
c语言题中 (i & 1) (y += i*i*i) :(x += i*i);句话什么意思
#include
int main(void)
{
unsigned int m,n,i,x,y;
while (scanf("%u%u",&m,&n) = EOF)
{
if (m > n)
{
i = n;
n = m;
m = i;
}
x = y = 0;
for (i = m ; i

c语言题中 (i & 1) (y += i*i*i) :(x += i*i);句话什么意思#include int main(void){unsigned int m,n,i,x,y;while (scanf("%u%u",&m,&n) = EOF){if (m > n){i = n;n = m;m = i;}x = y = 0;for (i = m ; i
由于变量i是一个无符号数,所以表达式 (i & 1)实际上就是判断i是否是奇数,是的话表达式的值为1,否则是0 
所以语句
 (i & 1) ?(y += i*i*i) :(x += i*i);
实际上就是
if(i%2!=0)
{
    y += i*i*i;
}
else
{
    x += i*i;
}