第二章编程题:
(1)
#include<iostream>
using namespace std;
int main()
{
cout << "My name is Zhang San."<<endl;
cout << "My address is California."<<endl;
return 0;
}
~
(2)
#include<iostream>
using namespace std;
int change(int Long);
int main()
{
cout << "enter the length in long:" << endl;
int Long;
cin >> Long;
cout << Long << " long = " << change(Long) << " yard" << endl;
}
int change(int Long)
{
return Long*220;
}
(3)
#include<iostream>
using namespace std;
void output1();
void output2();
int main()
{
output1();
output1();
output2();
output2();
return 0;
}
void output1()
{
cout << "Three blind mice" << endl;
}
void output2()
{
cout << "See how they run" << endl;
}
(4)
#include <iostream>
using namespace std;
int year_to_month(int age);
int main()
{
cout << "Please enter your age:" << endl;
int age;
cin >> age;
cout << "Your age include " << year_to_month(age) << " months." << endl;
return 0;
}
int year_to_month(int age)
{
return age*12;
}