测试时分开测试
#include <iostream>
void threeTest1();
void threeTest2();
void fiveTest1(float celsius);
void sixTest1(double lightYears);
void sevenTest1(int hour,int minute);
int main()
{
//1
std::cout<<"姓名:Ryan"<<std::endl;
std::cout<<"地址:深圳"<<std::endl;
//2
int number;
std::cout<<"请输入你的距离长度:";
std::cin>>number;
std::cout<<"长度为:"<<number*220<<"码"<<std::endl;
//3
threeTest1();
threeTest1();
threeTest2();
threeTest2();
//4
int age;
std::cout<<"Enter your age:";
std::cin>>age;
std::cout<<"Your age:"<<age*12<<std::endl;;
//5
float celsius;
std::cout<<"Please enter a Celsius value:";
std::cin>>celsius;
fiveTest1(celsius);
//6
double lightY;
std::cout<<"Enter the number of light years :";
std::cin>>lightY;
sixTest1(lightY);
//7
int hour,minute;
std::cout<<"Enter the number of hours :";
std::cin>>hour;
std::cout<<"Enter the number of minutes :";
std::cin>>minute;
sevenTest1(hour,minute);
}
void threeTest1()
{
std::cout<<"Three blind mice"<<std::endl;
}
void threeTest2()
{
std::cout<<"See how they run"<<std::endl;
}
void fiveTest1(float celsius)
{
std::cout<<celsius<<" degrees Celsius is "
<<celsius*1.8+32.0
<<" degress Fahrenheit."
<<std::endl;
}
void sixTest1(double lightYears)
{
std::cout<<lightYears<<" light years = "
<<lightYears*63240
<<" astronomical units."
<<std::endl;
}
void sevenTest1(int hour,int minute)
{
//时间不在规定范围内无效直接返回,不执行之后的语句
if(!(hour<24)||!(minute<60))
{
std::cout<<"Enter is invalid"<<std::endl;
return;
}
std::cout<<"Time: "<<hour<<":"<<minute
<<std::endl;
}