#include <stdio.h>
#include <Windows.h>
#define PRI printf
int main(void)
{
float a,b;
double add(float, float);
float mins(float, float);
double times(float, float);
double by(float, float);
double power(float,int);
double result;//存储结果
char ope,next;
PRI("Please enter the formula:");
scanf("%d%c%d",&a,&ope,&b);
switch(ope)
{
case *+*:result = add(a,b);
case *-*:result = mins(a,b);
case ***:result = times(a,b);
case */*:result = by(a,b);
case *^*:result = power(a,b);
}
PRI("Result is %-7.2lf",result);//输出结果
system("pause");
return 0;
}
double add(float a, float b)
{
return (a+b);
}
float mins(float a, float b)
{
return (a-b);
}
double times(float a, float b)
{
return (a*b);
}
double by(float a, float b)
{
return (a/b);
}
double power(float a,int b)
{
double i,c;
for (i=1,c=1; i<=b; i++)
c *= a;
return c;
}
求大神
#include <Windows.h>
#define PRI printf
int main(void)
{
float a,b;
double add(float, float);
float mins(float, float);
double times(float, float);
double by(float, float);
double power(float,int);
double result;//存储结果
char ope,next;
PRI("Please enter the formula:");
scanf("%d%c%d",&a,&ope,&b);
switch(ope)
{
case *+*:result = add(a,b);
case *-*:result = mins(a,b);
case ***:result = times(a,b);
case */*:result = by(a,b);
case *^*:result = power(a,b);
}
PRI("Result is %-7.2lf",result);//输出结果
system("pause");
return 0;
}
double add(float a, float b)
{
return (a+b);
}
float mins(float a, float b)
{
return (a-b);
}
double times(float a, float b)
{
return (a*b);
}
double by(float a, float b)
{
return (a/b);
}
double power(float a,int b)
{
double i,c;
for (i=1,c=1; i<=b; i++)
c *= a;
return c;
}
求大神




