cin >> sel;
switch(sel)
{
case 1:
cin >> ...;
cout << getEarning(...);
break;
case 2:
cin >> ...;
cout << getEarning(...);
break;
case 3:
cin >> ...;
cout << getEarning(...);
break;
case 4:
cin >> ...;
cout << getEarning(...);
break;
default:
break;
}
return 0;
}
来源:
#include
using namespace std;
double getEarning(double salary ,int absenceDays)
{
return (salary -salary*absenceDays/22);
}// admin
double getEarning(double baseSalary ,double salesSum,double rate) {
return (baseSalary + salesSum*rate);
}
double getEarning(int workPieces,double wagePerPiece)
{
return (workPieces*wagePerPiece);
}
double getEarning(double hours ,double wagePerHour)
{
return (hours*wagePerHour);
}
int main()
{
int kind = 0 ;
cout << "Please select..." << endl;
cout << "1: Manager." << endl;
cout << "2: Sales Man." << endl;
cout << "3: Pieces Worker." << endl;
cout << "4: Hour-Worker." << endl;
cout << "Others: Quit" << endl;
cin >> kind ;
switch(kind)
{
case 1:
{
double salary ;
int abDays;
cin>>salary>>abDays;
cout< break; } case 2: { double base ; double salesSum; double rate; cin>>base>>salesSum>>rate; cout< break; } case 3: { int workPieces; double wagePerPiece; cin>>workPieces>>wagePerPiece; cout< break; } case 4: { double hours; double wagePerHour; cin>>hours>>wagePerHour; cout< break; } default: break; } // cout< // cout< // cout< // cout< return 0 ; } #include using namespace std; void Math(float a , float b ,float& sum,float &sub,float&pro) { sum = a+ b ; sub = a-b ; pro = a*b ; } int main() { float sum = 0 ; float sub = 0 ; float pro = 0 ; float a = 0 ; float b = 0 ; cin>>a>>b; Math(a,b,sum,sub,pro); cout< } #include using namespace std; template T cg(T &a ,T& b) { T c ; c = a ; a = b ; b = c ; } int main() { int a = 0 ; int b = 0 ; char c = 0 ; char d = 0 ; cin>>a>>b>>c>>d;