-1 c++ visual-c++ c++11
为什么下面这段代码没有返回像... 100 90 80 70 60 50 40 30 20这样的系列,它返回数字10?
using namespace std;
int main()
{
int cont;
for(cont=100; cont>=20; cont-=10);
{
cout<< " "<<cont;
}
cout<< "\n";
system("pause");
}
Run Code Online (Sandbox Code Playgroud)
抱歉我的愚蠢问题..我现在开始学习c ++
谢谢
for(cont=100; cont>=20; cont-=10);
?
Run Code Online (Sandbox Code Playgroud)
删除它;.
您的代码与以下内容相同:
for(cont=100; cont>=20; cont-=10) { }
{
cout<< " "<<cont;
}
Run Code Online (Sandbox Code Playgroud)
循环将继续从10减去count直到count>=20不满足,然后它将打印值cont10,这将是10.
提示:使用调试器,它是您最好的朋友.
| 归档时间: |
|
| 查看次数: |
128 次 |
| 最近记录: |