第二章课后编程练习
18 //第二章课后编程练习1
#include <iostream>
using namespace std;
int main()
{
cout << "my name is : " << "wang ming\n";
cout << "my address: " << "dalian";
cin.get();
return 0;
}
19 //第二章课后编程练习2
#include <iostream>
using namespace std;
int main()
{
int n;
double sum;
cin >> n;
sum = n * 220;
cout << n << " long is " << sum << "码";
cin.get();
return 0;
}
20 //第二章课后编程练习3
#include <iostream>
using namespace std;
void c1(void);
void c2(void);
int main()
{
c1();
c1();
c2();
c2();
cin.get();
return 0;
}
void c1(void)
{
cout << "Three blind mice\n";
}
void c2(void)
{
cout << "see how they run\n";
}
21//第二章课后编程练习4
#include <iostream>
using namespace std;
int main()
{
int n;
int mouth;
cout << "enter your age :";
cin >> n;
mouth = n * 12;
cout << mouth;
cin.get();
cin.get();
return 0;
}
22 //第二章课后编程练习5
#include <iostream>
using namespace std;
double c1(double n1);
int main()
{
double n;
cout << "Place enter a Celsius value: ";
cin >> n;
cout << n << " degrees Celsius is " << c1(n) << " degrees Fahrenheit, ";
cin.get();
cin.get();
return 0;
}
double c1(double n1)
{
double fahre;
fahre = 1.8 * n1 + 32;
return fahre;
}
23//第二章课后编程练习6
#include <iostream>
using namespace std;
double c1(double n1);
int main()
{
double n;
cout << " enter a number of light years: ";
cin >> n;
cout << n << " light year = " << c1(n) << " units, ";
cin.get();
cin.get();
return 0;
}
double c1(double n1)
{
double fahre;
fahre = n1 * 63240;
return fahre;
}
24//第二章课后编程练习7
#include <iostream>
using namespace std;
void c1(int n1, double n2);
int main()
{
int n1;
double n2;
cout << " enter a number of hours: ";
cin >> n1;
cout << " enter a number of minutes: ";
cin >> n2;
cout << endl;
c1(n1, n2);
cin.get();
cin.get();
return 0;
}
void c1(int n1, double n2)
{
cout << "Time:" << n1 << ":" << n2;
}
在这里插入代码片