第二章
程序清单2.1 myfirst.cpp
//myfirst.cpp -- displays a message
#include<iostream>
int main()
{
using namespace std;
cout << "Come up and C++ me some time.";
cout << endl;
cout << "You won't regret it!" << endl;
cin.get();
return 0;
}
程序清单2.2 carrots.cpp
#include<iostream>
int main()
{
using namespace std;
int carrots;//
carrots = 25;
cout << "I hava ";
cout << carrots;
cout << " carrots.";
cout << endl;
carrots = carrots - 1;
cout << "Crunch,crunch.Now I have " << carrots << " carrots." << endl;
cin.get();
return 0;
}
程序清单2.3 getinfo.cpp
#include<iostream>
int main()
{
using namespace std;
int carrots;
cout << "How many carrots do you have ?