2.7-3
#include<iostream>
using namespace std;
void mice();
void oneint();
int main()
{
mice();
mice();
oneint();
oneint();
system("pause");
}
void mice()
{
cout<<"There blind mice\n";
}
void oneint()
{
cout<<"See how they run\n";
}
2.7-4
#include<iostream>
using namespace std;
int month(int x);
int main()
{
int age;
cout<<"Enter your age:";
cin>>age;
cout<<month(age)<<endl;
system("pause");
return 0;
}
int month(int x)
{
return x*12;
}
2.7-5
#include<iostream>
using namespace std;
double Fahrenheit(int x);
int main()
{
cout<<"Please enter a Celsius value:";
int Celsius;
cin>>Celsius;
cout<<Celsius<<" degrees Celsius is "<<Fahrenheit(Celsius)<<" degrees Fahrenheit\n.";
system("pause");
return 0;
}
double Fahrenheit(int x)
{
return x*1.8+32.0;
}
2.7-6
#include<iostream>
using namespace std;
double AstroUnits(double x);
int main()
{
cout<<"Enter the number of light years:";
double LightYear;
cin>>LightYear;
cout<<LightYear<<" lightyear = "<<AstroUnits(LightYear)<<" astronomical units.\n.";
system("pause");
return 0;
}
double AstroUnits(double x)
{
return 63240*x;
}
2.7-7
#include<iostream>
using namespace std;
void Time(int x,int y);
int main()
{
int hours,minutes;
cout<<"Enter the number of hours:";
cin>>hours;
cout<<"Enter the number of minutes:";
cin>>minutes;
Time(hours,minutes);
system("pause");
return 0;
}
void Time(int x,int y)
{
cout<<"Time:"<<x<<":"<<y<<endl;
}
posted on
浙公网安备 33010602011771号