-
#include <iostream>
int stonetolb(int);
int main()
{
using namespace std;
cout << "zzz ";
cout << "闵行"<<endl;
return 0;
}
- 编写一个程序,要求用户输入一个以long为单位的距离,然后转换成码,(一long = 220码)
#include <iostream>
int distanctransform(int);
int main()
{
using namespace std;
int longs;
cout << "Enter the distance : ";
cin >> longs;
int yard = distanctransform(longs);
cout << longs << "longs = ";
cout << yard << "yard "<<endl;
return 0;
}
int distanctransform(int st)
{
return st*220;
}
- 编写一个C++程序,它使用3个用户定义的函数(包括main)。
Three blind mice
Three blind mice
See how they run
See how they run
其中一个函数要调用两次,该函数生成前两行,另一个函数也被调用两次,并生成剩余输出。
#include <iostream>
int send1();
int send2();
using namespace std;
int main()
{
send1();
send2();
return 0;
}
int send1()
{
cout << "Three blind mice" << endl;
cout << "Three blind mice" << endl;
return 0;
}
int send2()
{
cout << "See how they run" << endl;
cout << "See how they run" << endl;
return 0;
}
- 编写一个程序,让用户输入年龄,显示该年龄包含几个月。
#include <iostream>
using namespace std;
int transforms(int);
int main()
{
int year;
cout << "Enter the your age:";
cin >> year ;
int month = transforms(year);
cout << "so your month = "<< month << endl;
return 0;
}
int transforms(int ss)
{
return ss*12;
}
- 编写一个程序,其中的main()调用一个用户自定义的函数(以摄氏度转华氏度),按以下格式用户输入摄氏温度值并显示结果。
please enter a Celsius value :20
20 degrees Cesius is 68 degrees Fahrenheit
#include <iostream>
using namespace std;
int transforms(int);
int main()
{
int year;
cout << "please enter a Celsius value :";
cin >> year ;
int month = transforms(year);
cout << year << " degrees Cesius is: "<< month << " degrees Fahrenheit" <<endl;
return 0;
}
int transforms(int ss)
{
return ss * 3.4;
}