#include <iostream>
using namespace std;
int main()
{
cout << "小明" << ' ' << "来自中国" << endl;
}
2 输入以long为单位的距离,转换为码(一long等于220码
#include <iostream>
using namespace std;
int convert(int a)
{
return a * 220;
}
int main()
{
cout << "输入一个距离" << endl;
int l = 0;
cin >> l;
cout << l << " long " << "equals to " << convert(l) << " 码" << endl;
}
3 使用3个用户定义的函数输出四句诗
#include <iostream>
using namespace std;
void out_1()
{
cout << "Three blind mice" << endl;
}
void out_2()
{
cout << "See how they run" << endl;
}
int main()
{
out_1();out_1();out_2();out_2();
return 0;
}
4 输入年龄,输出包含几个月
#include <iostream>
using namespace std;
int out_month(int input_age)
{
return input_age * 12;
}
int main()
{
cout <<"Enter your age: " << endl;
int age;
cin >> age;
cout << "Your age contains " << out_month(age) << " months"<< endl;
return 0;
}