C++题目—急!!!

来源:百度知道 编辑:UC知道 时间:2024/06/28 07:27:28
4. 设一个函数,调用它时,每次实现不同的功能: (1)求三个数之平方和;(2)求三个数之最大值;(3)求三个数之积。要求: (1)在主函数中输入3个数a,b,c,并输出a,b的平方和、最大值和三个数的乘积。 (2)分别编写函数add()、max( )、mul()计算平方和、最大值和三个数的乘积。 (3) 编写函数process(),分别调用函数add()、sub()、mul()。

#include <iostream>
using namespace std;
/*
4. 设一个函数,调用它时,每次实现不同的功能:
(1)求三个数之平方和;
(2)求三个数之最大值;
(3)求三个数之积。
要求:
(1)在主函数中输入3个数a,b,c,并输出a,b的平方和、最大值和三个数的乘积。
(2)分别编写函数add()、max( )、mul()计算平方和、最大值和三个数的乘积。
(3) 编写函数process(),分别调用函数add()、sub()、mul()。
*/
int add(int a,int b,int c)
{
return a+b+c;
}
int sub(int a,int b,int c)
{ int temp=a;
if (a<b)
{
temp=b;
}
if (temp<c)
{
return c;
}
else
{
return temp;
}

}
int mul(int a,int b,int c)
{
return a*b*c;
}
void process(int a,int b,int c)
{
add(a,b,c);
sub(a,b,c);
mul(a,b,c);
}
void main()
{ char a,b,c;
int d,e,f;
char ch='a';
cout<<"input 3 int num the 1st one:"<<endl;
cin>>a;
cout<<"the 2nd one:"<<endl;<