羊了个羊的代码
#include <iostream>
using namespace std;
int main()
{
int sheep = 1; // 初始化羊的数量为1
cout << "一只羊:" << sheep << endl;
// 迭代4次,每次增加一只羊
for (int i=0; i<4; i++) {
sheep++; // 增加一只羊
cout << "再来一只羊:" << sheep << endl;
}
cout<<"总共有 "<<sheep<<" 只小羊了。";
return 0;
}
免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。