第一题:
#include <iostream>
using namespace std;
int main(void)
{
cout << "luxiao " << "shanghai university " << endl;
return 0;
}
第二题:
#include <iostream>
using namespace std;
int change(int n);
int main()
{
int distance;
cout<<"Please enter a distance:";
cin>>distance;
cout<<distance<<" longs = "<<change(distance)<<" yards ."<<endl;
return 0;
}
int change(int n)
{
return n*220;
}
第三题:
#include <iostream>
using namespace std;
void function1();
void function2();
int main()
{
function1();
function2();
return 0;
}
void function1()
{
cout<<"Three blind mice"<<endl;
cout<<"Three blind mice"<<endl;
}
void function2()
{
cout<<"See how they run"<<endl;
cout<<"See how they run"<<endl;
}
第四题:
#include <iostream>
using namespace std;
int main()
{
int age;
cout << "Enter your age :";
cin >> age;
cout << age*12 <<" months"<<endl;
return 0;
}
第五题:
#include <iostream>
using namespace std;
double change(double n);
int main()
{
double celsius;
cout<<"Please enter a Celsius value:";
cin>>celsius;
cout<<celsius<<" degrees celsuis is "<<change(celsius)<<" Fehrenheit."<<endl;
return 0;
}
double change(double n)
{
return 1.8*n+32.0;
}
第六题:
#include <iostream>
using namespace std;
double change(double n);
int main()
{
cout<<"Enter the number of light years:";
double year;
cin>>year;
cout<<year<<" light years = "<<change(year)<<" astronomical units."<<endl;
return 0;
}
double change(double n)
{
return n*63240;
}
第七题:
#include <iostream>
using namespace std;
void time(int a, int b);
int main()
{
cout<<"Enter the number of hours:";
int hours;
cin>>hours;
cout<<"Enter the number of minutes:";
int minutes;
cin>>minutes;
time(hours,minutes);
return 0;
}
void time(int a, int b)
{
cout<<"Time: "<<a<<":"<<b<<endl;
}