这两个程序有什么区别?对于第一个程序,我的输出为9,对于第二个程序,我的输出为10。
#include <iostream>
using namespace std; // So we can see cout and endl
int main()
{
int x = 0; // Don't forget to declare variables
while ( x < 10 ) { // While x is less than 10
cout << x << endl;
x++; // Update x so the condition can be met eventually
}
cin.get();
}
Run Code Online (Sandbox Code Playgroud)
#include <iostream>
using namespace std; // So we can see cout and endl
int main()
{
int x = 0; …Run Code Online (Sandbox Code Playgroud) c++ ×1