2.1 进入C++
#include<iostream>
int main()
{
using namespace std;
cout << "Come up and C++ me some time.";
cout << endl;
cout << "You won't regret it!"<< endl;
return 0;
}
2.2 C++语句
#include<iostream>
int main()
{
using namespace std;
int carrots;
carrots = 25;
cout << "I have ";
cout << carrots;
cout << " carrots";
cout << endl;
carrots = carrots -1;
cout << "Crunch,crunch. Now I have " << carrots <<" carrots" <<endl;
return 0;
}
2.3 其他语句
#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 -1;
cout << "Now you have " << carrots << " carrots." << endl;
return 0;
}