测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A29950. 面两段C++代码都是用于求1-10的和,其运行结果相同。通常说来,for循环都可以用while循环实现。( )int tnt;int i;tnt = 0;for (i = 1; i < 10 + 1; i++) tnt += i;cout << tnt << endl;----------------------------------int tnt;int i;tnt = 0;i = 1;wh…

判断题 较易

题目描述

面两段C++代码都是用于求1-10的和,其运行结果相同。通常说来,for循环都可以用while循环实现。(    )

int tnt;

int i;

tnt = 0;

for (i = 1; i < 10 + 1; i++)

      tnt += i;

cout << tnt << endl;

----------------------------------

int tnt;

int i;

tnt = 0;

i = 1;

while (i <= 10){

      tnt += i;

      i += 1;

}

cout << tnt << endl;

选项(单选)

上一题 下一题