#include <iostream>
#include <cmath>
using namespace std;
int main() {
int i = 0;
int square = 0;
// Write a while loop here:
while ((i <= 9) && square == pow(i, 2)) {
cout << i << square;
i++;
}
}
//Why is this not printing out
/* 0 0
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
*/
/有人可以向我彻底解释一下为什么这个while循环无法打印出这个数字序列吗?
我不明白为什么它只打印出00而不是那个数字列表。有人能告诉我为什么这个while循环不能正常工作吗?/
square
被初始化为零,之后再也没有被更新过。你是不是想要赋值给它呢...? - ravnsgaard