#include <iostream>
int main()
{
using namespace std;
int carrots;
cout << "how many carrots do you have?" << endl;
cin >> carrots;
cout << "here are two more.";
carrots = carrots + 2;
cout << "Now you have " << carrots << "carrots." << endl;
return 0;
}
按理说我应该看到这样的结果:
how many carrots do you have?
12
here are two more.now you have 14 carrots.
但是我只有这一行
how many carrots do you have?
底下的就没有了
那你在屏幕上输入 12 然后回车。。。
cin >> carrots;
这里在等待你的控制台输入,你需要输入一个数字,然后回车,这一行代码才能继续。同时把你的输入赋值给变量carrots