C语言求助题目有图,希望过程详细一些!!
2021-03-15
a[i] = 10* (i+2-5*(i>2)) % 6;
当i = 0时候
a[0] = 10* (0+2-5*(0>2)) % 6; //(0>2)为判断语句,0大于2为假 ,结果是0
= 10* (0+2-5*0) % 6
= 20 % 6 //取余数
= 2
当i = 1时候
a[1] = 10* (1+2-5*(1>2)) % 6; //(1>2)为判断语句,1大于2为假 ,结果是0
= 10* (1+2-5*0) % 6
= 30 % 6 //取余数
= 0
当i = 2时候
a[2] = 10* (2+2-5*(2>2)) % 6; //(2>2)为判断语句,2大于2为假 ,结果是0
= 10* (2+2-5*0) % 6
= 40 % 6 //取余数
= 4
当i = 3时候
a[3] = 10* (3+2-5*(3>2)) % 6; //(3>2)为判断语句,3大于2为真 ,结果是1
= 10* (3+2-5*1) % 6
= 0 % 6 //取余数
= 0
当i = 4时候
a[4] = 10* (4+2-5*(4>2)) % 6; //(4>2)为判断语句,4大于2为真 ,结果是1
= 10* (4+2-5*1) % 6
= 10 % 6 //取余数
= 4
当i = 5时候
a[5] = 10* (5+2-5*(5>2)) % 6; //(5>2)为判断语句,5大于2为真 ,结果是1
= 10* (5+2-5*1) % 6
= 20 % 6 //取余数
= 2
运行结果如下: