2022.6.11 学习cout,cin的使用方法以及变量的定义。
#include<iostream>
int main(void)
{
using namespace std;
int carrots;
carrots = 25;
cout << "l have ";
cout << carrots;
cout << " carrots";
cout << endl;
carrots = carrots -1;
cout << "Now i have " << carrots << " carrots" << endl;
return 0;
}
输出结果:
#include<iostream>
int main(void)
{
using namespace std;
int carrots;
cout << "How many carrots do you have?" << endl;
cin >> carrots;
cout << "Here two more.";
carrots = carrots + 2;
cout << "Now you have " << carrots << " carrots." << endl;
return 0;
}
输出结果: