|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 1627550352 于 2014-10-24 21:11 编辑
#include "stdlib.h "
#include "stdafx.h"
#include<iostream>
using namespace std;
int calc(int a);
int calc(int a, int b);
int calc(int a,int b,int c);
int calc(int a)
{
int f;
f = a*a;
return f;
}
int calc(int a, int b)
{
int f;
f = a*b;
return f;
}
int calc(int a, int b, int c)
{
int f;
f = a + b + c;
return f;
}
int main()
{
int a, b, c,d,temp;
cout << "选择功能:1为求参数平方值;2为求两个参数的积;3为求三个参数的和"<<"\n\n";
cout << "请输入选择的功能数字"<<"\n\n";
//cin.ignore(100, '\n');
//cout << "\n";
cin >> temp;
cin.ignore(100, '\n');
cout << "\n";
switch (temp)
{
case '1':
cout << "请输入一个参数a的值"<<"\n\n";
cin >> a;
d = calc(a);
break;
case '2':
cout << "请输入参数a、b的值"<<"\n\n";
cin >> a;
cin >> b;
d = calc(a, b);
break;
case '3':
cout << "请输入参数a、b、c的值"<<"\n\n";
cin >> a;
cin >> b;
cin >> c;
d = calc(a, b, c);
break;
default:
temp = 'E';
break;
}
if (temp != 'E')
{
if (temp == '1')
{
cout << "a" << "*" << "a" << "=" << d << "\n\n";
}
else if (temp == '2')
{
cout << "a" << "*" << "b" << "=" << d << "\n\n";
}
else if (temp == '3')
{
cout << "a" << "+" << "b" <<"c"<< "=" << d << "\n\n";
}
}
else
{
cout << "输入错误!" << "\n\n";
}
std::cout << "请输入任何字符结束!" << "\n\n";
system("pause");
return 0;
}
为什么实现不了功能呢
|
-
|