这里有一个悲惨的程序:
#include<iostream>
using namespace std;
int main()
{
int n;
while(n)
{
cout<<
"1010";
}
return 0;
}
运行一下 那么这是为甚么呢?我们兹道,while()里面是判断循环可否循环,而没有一个东西来控制n,所以n一直为1,为对,所以加一个就可以了。
#include<iostream>
using namespace std;
int main()
{
int n=
1;
while(n)
{
n--;
cout<<
"1010";
}
return 0;
}
我们下次见。
转载请注明原文地址: https://www.6miu.com/read-74001.html