1.
# include <iostream>
int main ( ) {
using namespace std;
cout << "my name " << "my address" << endl;
return 0 ;
}
2.
# include <iostream>
int main ( ) {
using namespace std;
int dis;
cout << "请输入一个以long为单位的距离:" ;
cin >> dis;
cout << "转码结果为:" << dis * 220 << "码." ;
return 0 ;
}
3.
# include <iostream>
void state ( ) ;
void method ( ) ;
int main ( ) {
state ( ) ;
state ( ) ;
method ( ) ;
method ( ) ;
return 0 ;
}
void state ( ) {
using namespace std;
cout << "Three blind mice." << endl;
}
void method ( ) {
using namespace std;
cout << "See how they run." << endl;
}
4.
# include <iostream>
int agetomonth ( int ) ;
int main ( ) {
using namespace std;
int age;
cout << "Enter your age: " ;
cin >> age;
cout << "age to month: " << agetomonth ( age) ;
return 0 ;
}
int agetomonth ( int age) {
int month;
month = age * 12 ;
return month;
}
5.
# include <iostream>
double cvalueTofvalue ( double ) ;
int main ( ) {
using namespace std;
double cvalue;
cout << "Please enter a Celsius value: " ;
cin >> cvalue;
cout << cvalue << " degrees Celsius is " << cvalueTofvalue ( cvalue)
<< " degrees Fahreheit." ;
return 0 ;
}
double cvalueTofvalue ( double cvalue) {
int fvalue;
fvalue = cvalue * 1.8 + 32.0 ;
return fvalue;
}
6.
# include <iostream>
double light_years_to_astro_units ( double ) ;
int main ( ) {
using namespace std;
double light_years;
cout << "Enter the number of light years: " ;
cin >> light_years;
cout << light_years << " light years = " << light_years_to_astro_units ( light_years)
<< " astronomical units." ;
return 0 ;
}
double light_years_to_astro_units ( double light_years) {
int astro_units;
astro_units = light_years * 63240 ;
return astro_units;
}
7.
# include <iostream>
void visualTime ( int , int ) ;
int main ( ) {
using namespace std;
int hours;
int minutes;
cout << "Enter the number of hours: " ;
cin >> hours;
cout << "Enter the number of minutes: " ;
cin >> minutes;
visualTime ( hours, minutes) ;
return 0 ;
}
void visualTime ( int hours, int minutes) {
using namespace std;
cout << "Time: " << hours << ':' << minutes;
}