1
#include <iostream> int main() { using namespace std; cout << "姓名: Mr.Lei" << endl; cout << "地址: 广东省深圳市龙岗区" << endl; system("pause"); return 0; }
2
#include <iostream> int main() { using namespace std; long x; cout << "请输入距离:" << endl; cin >> x; cout << x << " = " << x * 220 << " 码" << endl; system("pause"); return 0; }
3
#include <iostream> using namespace std; void showa(); void showb(); int main() { showa(); showa(); showb(); showb(); system("pause"); return 0; } void showa() { cout << "Three blind mice" << endl; } void showb() { cout << "See how they run" << endl; }
4
#include <iostream> int main() { using namespace std; int ages; cout << "请输入你的年龄: "; cin >> ages; cout << "你今年 " << ages << " 岁, 已经度过了 " << ages * 12 << " 个月." << endl; system("pause"); return 0; }
5
#include <iostream> double convert(float n); int main() { using namespace std; float a; cout << "请输入温度[摄氏度]: "; cin >> a; cout << a << " 摄氏度 = " << convert(a) << " 华氏度" << endl; system("pause"); return 0; } double convert(float n) { return (1.8*n + 32.0); }
6
#include <iostream> double convert(double n); int main() { using namespace std; double years; cout << "请输入光年: "; cin >> years; cout << years << " 光年 = " << convert(years) << " 天文单位." << endl; system("pause"); return 0; } double convert(double n) { return (n * 63240); }
7
#include <iostream> using namespace std; void convert(int n, int m); int main() { int hour; int min; cout << "请输入小时: "; cin >> hour; cout << "请输入分钟: "; cin >> min; convert(hour, min); system("pause"); return 0; } void convert(int n, int m) { cout << "时间: " << n << ":" << m << endl; }