error C2664: 'process' : cannot convert parameter 3 from 'float (void)' to 'float (__cdecl *)(float,float)'
None of the functions with this name in scope match the target type
请问是哪出问题
#include
#include
#include
//#include
char get();
char getfirst();
float shu();
void chu();
void process(float,float,float (*rk)(float,float));
float add();
float sub();
float mul();
float div();
float m,n;
float min,max;
int limit(float,float,float,float);
int main()
{
int ch;
//float m,n;
max=1000.0;
min=-100.0;
while((ch=get())!='q')
{
switch(ch)
{
case 'a':chu();
process(m,n,add);
break;
case 's':chu();
process(m,n,sub);
break;
case 'm':chu();
process(m,n,mul);
break;
case 'd':chu();
process(m,n,div);
break;
default:printf("错误");
break;
}
printf("再见");
return 0;
}
}
char get()
{
int ch;
printf("输入你的选择\n");
printf("a 加 s减\n");
printf("m 乘 d除\n");
printf("q 退\n");
ch=getfirst();
while((ch!='a')&&(ch!='s')&&(ch!='m')&&(ch!='d')&&(ch!='q'))
{
printf("输入amsdq的一个");
ch=getfirst();
}
return ch;
}
char getfirst()
{
int ch;
ch=getchar();
while(getchar()!='\n')
continue;
return ch;
}
float shu()
{
float m;
//float n;
char ch;
while(scanf("%f",&m)!=1)
{
while((ch=getchar())!='\n')
putchar(ch);
printf("不是数字麻烦输入数字");
}
return m;
}
void chu()
{
//float zhi;
printf("输入第一个数");
m=shu();
printf("输入第二个数");
n=shu();
while(limit(m,n,min,max))
{
printf("请输入有效数字");
m=shu();
n=shu();
}
}
void process(float m,float n,float (*rk)(float,float))
{
float zhi;
zhi=(*rk)(m,n);
printf("%f",zhi);
}
float add(float m,float n)
{
float zhi;
zhi=m+n;
return zhi;
}
float sub(float m,float n)
{
float zhi;
zhi=m-n;
return zhi;
}
float mul(float m,float n)
{
float zhi;
zhi=m*n;
return zhi;
}
float div(float m,float n)
{
float zhi;
while(n==0)
{
printf("输入其他的");
n=shu();
}
zhi=m/n;
return zhi;
}
int limit(float bejin,float end, float low, float hig)
{
int not_good=0 ;
if(bejinhig||endhig)
{
not_good=1;
}
return not_good;
}
|
|