平方和
#include <iostream>
using namespace std;
//请在这里编写两个sumOfSquare函数
int sumOfSquare(int m,int n)
{
return m*m+n*n;
}
double sumOfSquare(double m,double n)
{
return m*m+n*n;
}
int main(){
int m, n;
cout << "请输入两个整数:";
cin >> m >> n;
cout << "整数的平方和是:" << sumOfSquare(m, n) << endl;
double x, y;
cout << "请输入两个实数:";
cin >> x >> y;
cout << "实数的平方和是:" << sumOfSquare(x, y) << endl;
return 0;
}
长方体体积
#include<iostream>
#include<iomanip>
using namespace std;
int getVolume(int length, int width = 2, int height = 3);
int main()
{
const int X = 10, Y = 12, Z = 15;
cout << getVolume(X,Y,Z) << endl;
cout << getVolume(X, Y) << endl;
cout << getVolume(X) << endl;
system("pause");
return 0;
}
int getVolume(int length, int width, int height)
{
return length * width * height;
}
圆面积
#include <iostream>
using namespace std;
const double PI = 3.14159;
inline double calArea(double r){
double h=PI*r*r;
return h;
}
int main(){
double r= 3.0;
double area = calArea(r);
cout << area << endl;
return 0;
}