代码如下:
practice 1
#include<iostream> using namespace std; int main() { cout << "name:" << "tff" << endl; cout << "address:" << "Beijing" << endl; return 0; }practice 2
#include<iostream> using namespace std; int main() { double value_long, value_ma; cout << "Please input distance:"; cin >> value_long; value_ma = 200 * value_long; cout << "The distance in yards:" << value_ma << endl; system("pause"); return 0; }practice 3
#include<iostream> using namespace std; void function1(); void function2(); int main() { function1(); function2(); system("pause"); return 0; } void function1() { for (int i = 0; i < 2; i++) { cout << "Three blind mice" << endl; } } void function2() { for (int i = 0; i < 2; i++) { cout << "See how the run" << endl; } }practice 4
#include<iostream> using namespace std; int main() { int age, month; cout << "Please input your age:"; cin >> age; month = 12 * age; cout << "Contain " << month << " months!" << endl; system("pause"); return 0; }practice 5
#include<iostream> using namespace std; void tem_conversion(); int main() { tem_conversion(); system("pause"); return 0; } void tem_conversion() { double Celsius_tem, Fahrenheit_tem; cout << "Please enter a Celsius value:"; cin >> Celsius_tem; Fahrenheit_tem = 1.8 * Celsius_tem + 32.0; cout << Celsius_tem << " degrees Celsius is " << Fahrenheit_tem << " degrees Fahrenheit." << endl; }practice 6
#include<iostream> using namespace std; double LightYears_T_AstronomicalUnits(double light_years); int main() { double as_un, l_y; cout << "Enter the number of light years:"; cin >> l_y; as_un = LightYears_T_AstronomicalUnits(l_y); cout << l_y << " light years = " << as_un << " astronomical units." << endl; system("pause"); return 0; } double LightYears_T_AstronomicalUnits(double light_years) { double astronomical_units; astronomical_units = 63240 * light_years; return astronomical_units; }practice 7
#include<iostream> using namespace std; void show_time(int hours, int minutes); int main() { int hour, minute; cout << "Enter the number of hours:"; cin >> hour; cout << "Enter the number of minutes:"; cin >> minute; show_time(hour, minute); system("pause"); return 0; } void show_time(int hours, int minutes) { cout << "Time: " << hours << ":" << minutes << endl; }