C++帮助,

问题描述:

C++帮助,
#include
void getOption(int *option);
void getNumbers(int *option,float *number1,float *number2);
float calc(int *option,float *number1,float *number2);
void printResult(float number1,float number2,float result,int option);
main()
{
float outcome;
float number1,number2;
int option;
do
{ getOption (&option);
if (option = 5)
{
getNumbers(&option,&number1,&number2);
outcome=calc(&option,&number1,&number2);
printResult(number1,number2,outcome,option);
}
} while ( option!=5);
}
void getOption(int *option)
{
printf(":\n");
scanf("%f",number1);
scanf("%f",number2);
if (*option==4 && *number2==0)
printf("除数不能为零!\n");
} while(*option==4 && *number2==0);
}
float calc(int *option,float *number1,float *number2)
{
float result;
switch(*option)
{ case 1:result=*number1+ *number2; break;
case 2:result=*number1- *number2; break;
case 3:result=*number1* *number2; break;
case 4:result=*number1/ *number2; break;
}
return result;
}
void printResult(float number1,float number2,float result,int option)
{
switch (option)
{
case 1:printf("%.2f + %.2f = %.2f\n",number1,number2,result); break;
case 2:printf("%.2f - %.2f = %.2f\n",number1,number2,result); break;
case 3:printf("%.2f * %.2f = %.2f\n",number1,number2,result); break;
case 4:printf("%.2f / %.2f = %.2f\n",number1,number2,result); break;
}
}

#include//:\n");scanf("%f",number1); scanf("%f",number2);if (*option==4 && *number2==0) //意思为option为4(除号),并除数为0,不能计算printf("除数不能为零!\n");} while(*option==4 && *number2==0); //直到...