1个回答
展开全部
题1:关键知识点是static定义变量只会初始化一次
i的取值范围为1,2,3,4,5
i = 1: sum= 0 + 1 * 1 = 1, k = 1
i = 2: sum = 1 + 2 * 1 = 3, k=2
i = 3: sum = 3 + 2 * 3 = 9, k=6
i = 4: sum = 9 + 6 * 4 = 33, k=24
i = 5: sum = 33+24 * 5 = 153,k=120
所以sum最终值为:153
题2:关键知识点是static定义变量只会初始化一次
i的取值是1,2,3
i = 1: s = 1 * 1 * 2 = 2, x = 1 * 2 = 2
i = 2: s = 2 * 2 * 2 = 8, x = 2 * 2 =4
i = 3: s = 8 * 4 * 2 = 64, x = 4 * 2 = 8
所以s的最终值是64
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询