|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
大神帮我找下程序的毛病可以吗?我想实现的功能是判断输入几个数,然后函数重载。
#include<iostream>
using namespace std;
void calc(double a);
void calc(double a,double b);
void calc(double a,double b,double c);
int main()
{
char num;
double aa,bb,cc;
cout<<"请问你要输入几个数?"<<"\n";
num=cin.get();
switch(num)
{
case'1':
cout<<"xuan1";
cin>>aa>>"\n";
calc(aa);
break;
case'2':
cin>>aa>>bb>>"\n";
calc(aa,bb);
break;
case'3':
cin>>aa>>bb>>cc>>"\n";
calc(aa,bb,cc);
break;
}
return 0;
}
void calc(double a)
{
double aaa;
aaa=a*a;
cout<<aaa<<"\n";
}
void calc(double a,double b)
{
double bbb;
bbb=a*b;
cout<<bbb<<"\n";
}
void calc(double a,double b,double c)
{
double ccc;
ccc=a+b+c;
cout<<ccc<<"\n";
}
|
|