- 编写一个C++程序,它显示您的姓名和地址。
#include <iostream>
int main()
{
using namespace std;
char name,address;
cout << "请输入您的姓名:";
cin >> name;
cout << "请输入您的地址:";
cin >> address;
cout << "您的名字是" << name << endl << "您的地址是" << address;
return 0;
}
2.编写一个C++程序,它要求用户输入一个以long为单位的距离,然后将它转换为码(一long等于220码)。
#include <iostream>
using namespace std;
double switch_d (double);
int main()
{
double long_d;
cout << "请输入转换距离:";
cin >> long_d;
cout << "一long等于" << switch_d (long_d) << "码";
}
double switch_d (double long_distance)
{
double ma = 220 * long_distance;
return ma;
}
3.编写一个C++程序,它使用3个用户定义的函数(包括main()),并生成下面的输出: Three blind mice Three blind mice See how they run See how they run
#include <iostream>
using namespace std;
void mice();
void see();
int main()
{
mice();
mice();
see();
see();
}
void mice()
{
cout << "Three blind mice"<<endl;
}
void see()
{
cout << "See how they run"<<endl;
}
|