//第2题//long to meters#include<iostream>intmain(){usingnamespace std;
cout <<"Enter the distance in long:";double distance;
cin >> distance;
cout <<"The distance in meters is "<< distance *220<< endl;return0;}
//第3题//two functions in this file#include<iostream>usingnamespace std;voidMyfunc2(void);voidMyfunc1(void);intmain(){Myfunc1();Myfunc1();Myfunc2();Myfunc2();return0;}voidMyfunc1(void){
cout <<"Three blind mice\n";}voidMyfunc2(void){
cout <<"See how they run\n";}
//第4题//display somebody's months#include<iostream>intAgetomonths(int age);intmain(){usingnamespace std;int age;
cout <<"Enter your age please.\n";
cin >> age;
cout <<"OK,the months of your age is "<<Agetomonths(age)<<"."<< endl;return0;}intAgetomonths(int age){int months = age *12;return months;}
第5题
//Celsius to Fahrenheit#include<iostream>doubleCelToFar(double calsius);intmain(){usingnamespace std;double celsius;
cout <<"Please enter a Celsius value:";
cin >> celsius;
cout << celsius;
cout <<" degrees Celsius is "<<CelToFar(celsius)<<" degrees Farenheit."<< endl;return0;}doubleCelToFar(double celsius){double fahrenheit = celsius *1.8+32.0;return fahrenheit;}
第6题
//light year to astronomical unit#include<iostream>doubleLigToAst(double lightyear);intmain(){usingnamespace std;double lightyear;
cout <<"Enter the number of light year:";
cin >> lightyear;
cout << lightyear;
cout <<" lightyear = "<<LigToAst(lightyear)<<" astronomical units."<< endl;return0;}doubleLigToAst(double lightyear){double astrunit = lightyear *63240;return astrunit;}
第7题
//输入一个时间,显示,并且求出与现在的时间差#include<iostream>voidShowInputTime(int,int);voidShowNowTime(void);intmain(){usingnamespace std;ShowNowTime();int hours, minutes;
cout <<"Enter the number of hours:";
cin >> hours;
cout <<"Enter the number of minutes:";
cin >> minutes;ShowInputTime(hours, minutes);return0;}voidShowInputTime(int hours,int minutes){usingnamespace std;
cout <<"Time: "<< hours <<":"<< minutes << endl;}voidShowNowTime(void){usingnamespace std;
cout <<"Now time is "<<__TIME__<< endl;}